mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
reconcile types
This commit is contained in:
35
appmgr/Cargo.lock
generated
35
appmgr/Cargo.lock
generated
@@ -151,7 +151,7 @@ dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"clang-sys",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"env_logger 0.7.1",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
@@ -873,7 +873,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"humantime 1.3.0",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime 2.1.0",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
@@ -1241,6 +1254,12 @@ dependencies = [
|
||||
"quick-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.11"
|
||||
@@ -1285,12 +1304,12 @@ source = "git+https://github.com/Start9Labs/hyper-ws-listener.git?branch=main#d5
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.13.0",
|
||||
"env_logger",
|
||||
"env_logger 0.9.0",
|
||||
"futures",
|
||||
"hyper",
|
||||
"log",
|
||||
"sha-1",
|
||||
"tokio 1.8.1",
|
||||
"tokio 1.9.0",
|
||||
"tokio-tungstenite",
|
||||
]
|
||||
|
||||
@@ -2528,9 +2547,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.9.6"
|
||||
version = "0.9.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16"
|
||||
checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"cfg-if 1.0.0",
|
||||
@@ -3184,7 +3203,7 @@ dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
"pin-project",
|
||||
"tokio 1.8.1",
|
||||
"tokio 1.9.0",
|
||||
"tungstenite",
|
||||
]
|
||||
|
||||
@@ -3287,7 +3306,7 @@ dependencies = [
|
||||
"httparse",
|
||||
"input_buffer",
|
||||
"log",
|
||||
"rand 0.8.3",
|
||||
"rand 0.8.4",
|
||||
"sha-1",
|
||||
"thiserror",
|
||||
"url",
|
||||
|
||||
@@ -99,12 +99,24 @@ impl RpcContext {
|
||||
Ok(Self(seed))
|
||||
}
|
||||
pub async fn package_registry_url(&self) -> Result<Url, Error> {
|
||||
Ok(crate::db::DatabaseModel::new()
|
||||
.server_info()
|
||||
.registry()
|
||||
.get(&mut self.db.handle(), false)
|
||||
.await?
|
||||
.to_owned())
|
||||
Ok(
|
||||
if let Some(market) = crate::db::DatabaseModel::new()
|
||||
.server_info()
|
||||
.package_marketplace()
|
||||
.get(&mut self.db.handle(), false)
|
||||
.await?
|
||||
.to_owned()
|
||||
{
|
||||
market
|
||||
} else {
|
||||
crate::db::DatabaseModel::new()
|
||||
.server_info()
|
||||
.eos_marketplace()
|
||||
.get(&mut self.db.handle(), false)
|
||||
.await?
|
||||
.to_owned()
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
impl Context for RpcContext {
|
||||
|
||||
@@ -39,9 +39,33 @@ impl Database {
|
||||
"http://privacy34kn4ez3y3nijweec6w4g54i3g54sdv7r5mr6soma3w4begyd.onion"
|
||||
.parse()
|
||||
.unwrap(),
|
||||
updating: false,
|
||||
registry: "https://beta-registry-0-3.start9labs.com".parse().unwrap(),
|
||||
status: ServerStatus::Running,
|
||||
eos_marketplace: "https://beta-registry-0-3.start9labs.com".parse().unwrap(),
|
||||
package_marketplace: None,
|
||||
wifi: WifiInfo {
|
||||
ssids: Vec::new(),
|
||||
connected: None,
|
||||
selected: None,
|
||||
},
|
||||
unread_notification_count: 0,
|
||||
specs: ServerSpecs {
|
||||
cpu: Usage {
|
||||
used: 0_f64,
|
||||
total: 1_f64,
|
||||
},
|
||||
disk: Usage {
|
||||
used: 0_f64,
|
||||
total: 1_f64,
|
||||
},
|
||||
memory: Usage {
|
||||
used: 0_f64,
|
||||
total: 1_f64,
|
||||
},
|
||||
},
|
||||
connection_addresses: ConnectionAddresses {
|
||||
tor: Vec::new(),
|
||||
clearnet: Vec::new(),
|
||||
},
|
||||
},
|
||||
package_data: AllPackageData::default(),
|
||||
broken_packages: Vec::new(),
|
||||
@@ -62,9 +86,51 @@ pub struct ServerInfo {
|
||||
version: Version,
|
||||
lan_address: Url,
|
||||
tor_address: Url,
|
||||
updating: bool,
|
||||
registry: Url,
|
||||
status: ServerStatus,
|
||||
eos_marketplace: Url,
|
||||
package_marketplace: Option<Url>,
|
||||
wifi: WifiInfo,
|
||||
unread_notification_count: u64,
|
||||
specs: ServerSpecs,
|
||||
connection_addresses: ConnectionAddresses,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ServerStatus {
|
||||
Running,
|
||||
Updating,
|
||||
BackingUp,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct WifiInfo {
|
||||
pub ssids: Vec<String>,
|
||||
pub selected: Option<String>,
|
||||
pub connected: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct ServerSpecs {
|
||||
pub cpu: Usage,
|
||||
pub disk: Usage,
|
||||
pub memory: Usage,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Usage {
|
||||
pub used: f64,
|
||||
pub total: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct ConnectionAddresses {
|
||||
pub tor: Vec<String>,
|
||||
pub clearnet: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Serialize)]
|
||||
@@ -150,6 +216,8 @@ impl PackageDataEntryModel {
|
||||
pub struct InstalledPackageDataEntry {
|
||||
#[model]
|
||||
pub status: Status,
|
||||
#[model]
|
||||
pub manifest: Manifest,
|
||||
pub system_pointers: Vec<SystemPointerSpec>,
|
||||
#[model]
|
||||
pub current_dependents: IndexMap<PackageId, CurrentDependencyInfo>,
|
||||
@@ -158,13 +226,6 @@ pub struct InstalledPackageDataEntry {
|
||||
#[model]
|
||||
pub interface_addresses: InterfaceAddressMap,
|
||||
}
|
||||
impl InstalledPackageDataEntryModel {
|
||||
pub fn manifest(self) -> ManifestModel {
|
||||
let mut ptr = JsonPointer::from(self);
|
||||
ptr.pop_end();
|
||||
PackageDataEntryModel::from(ptr).manifest()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
|
||||
@@ -121,6 +121,7 @@ impl HasModel for Dependencies {
|
||||
pub struct DepInfo {
|
||||
pub version: VersionRange,
|
||||
pub optional: Option<String>,
|
||||
pub recommended: bool,
|
||||
pub description: Option<String>,
|
||||
pub critical: bool,
|
||||
#[serde(default)]
|
||||
|
||||
@@ -406,6 +406,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
dependency_errors: DependencyErrors::init(&mut tx, &manifest, ¤t_dependencies)
|
||||
.await?,
|
||||
},
|
||||
manifest: manifest.clone(),
|
||||
system_pointers: Vec::new(),
|
||||
current_dependents: {
|
||||
// search required dependencies
|
||||
|
||||
@@ -135,6 +135,8 @@ impl<S: AsRef<str>> AsRef<Path> for InterfaceId<S> {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Interface {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub tor_config: Option<TorConfig>,
|
||||
pub lan_config: Option<IndexMap<Port, LanPortConfig>>,
|
||||
pub ui: bool,
|
||||
|
||||
@@ -113,6 +113,7 @@ pub struct Manifest {
|
||||
pub upstream_repo: Url,
|
||||
pub support_site: Option<Url>,
|
||||
pub marketing_site: Option<Url>,
|
||||
pub donation_url: Option<Url>,
|
||||
#[serde(default)]
|
||||
pub alerts: Alerts,
|
||||
#[model]
|
||||
|
||||
@@ -95,7 +95,8 @@ impl HealthCheck {
|
||||
result: match res {
|
||||
Ok(()) => HealthCheckResultVariant::Success,
|
||||
Err((59, _)) => HealthCheckResultVariant::Disabled,
|
||||
Err((60, _)) => HealthCheckResultVariant::WarmingUp,
|
||||
Err((60, _)) => HealthCheckResultVariant::Starting,
|
||||
Err((61, message)) => HealthCheckResultVariant::Loading { message },
|
||||
Err((_, error)) => HealthCheckResultVariant::Failure { error },
|
||||
},
|
||||
})
|
||||
@@ -123,17 +124,19 @@ impl HealthCheckResult {
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(tag = "result")]
|
||||
pub enum HealthCheckResultVariant {
|
||||
WarmingUp,
|
||||
Disabled,
|
||||
Success,
|
||||
Disabled,
|
||||
Starting,
|
||||
Loading { message: String },
|
||||
Failure { error: String },
|
||||
}
|
||||
impl std::fmt::Display for HealthCheckResultVariant {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
HealthCheckResultVariant::WarmingUp => write!(f, "Warming Up"),
|
||||
HealthCheckResultVariant::Disabled => write!(f, "Disabled"),
|
||||
HealthCheckResultVariant::Success => write!(f, "Succeeded"),
|
||||
HealthCheckResultVariant::Disabled => write!(f, "Disabled"),
|
||||
HealthCheckResultVariant::Starting => write!(f, "Starting"),
|
||||
HealthCheckResultVariant::Loading { message } => write!(f, "Loading ({})", message),
|
||||
HealthCheckResultVariant::Failure { error } => write!(f, "Failed ({})", error),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user