mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
Merge branch 'integration/new-container-runtime' of github.com:Start9Labs/start-os into rebase/feat/domains
This commit is contained in:
@@ -412,7 +412,7 @@ pub struct StaticDependencyInfo {
|
||||
pub icon: DataUrl<'static>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(tag = "kind")]
|
||||
pub enum CurrentDependencyInfo {
|
||||
|
||||
@@ -385,6 +385,10 @@ impl NetService {
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ip(&self) -> Ipv4Addr {
|
||||
self.ip.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for NetService {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::ffi::OsString;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::os::unix::process::CommandExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
@@ -259,16 +260,24 @@ enum AllowedStatuses {
|
||||
OnlyRunning,
|
||||
OnlyStopped,
|
||||
Any,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ExportActionParams {
|
||||
#[ts(type = "string")]
|
||||
id: ActionId,
|
||||
metadata: ActionMetadata,
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ActionMetadata {
|
||||
name: String,
|
||||
description: String,
|
||||
id: String,
|
||||
warning: Option<String>,
|
||||
disabled: bool,
|
||||
#[ts(type = "{[key: string]: any}")]
|
||||
input: Value,
|
||||
allowed_statuses: AllowedStatuses,
|
||||
@@ -335,8 +344,17 @@ async fn get_system_smtp(
|
||||
) -> Result<Value, Error> {
|
||||
todo!()
|
||||
}
|
||||
async fn get_container_ip(context: EffectContext, _: Empty) -> Result<Value, Error> {
|
||||
todo!()
|
||||
async fn get_container_ip(context: EffectContext, _: Empty) -> Result<Ipv4Addr, Error> {
|
||||
match context.0.upgrade() {
|
||||
Some(c) => {
|
||||
let net_service = c.persistent_container.net_service.lock().await;
|
||||
Ok(net_service.get_ip())
|
||||
}
|
||||
None => Err(Error::new(
|
||||
eyre!("Upgrade on Weak<ServiceActorSeed> resulted in a None variant"),
|
||||
crate::ErrorKind::NotFound,
|
||||
)),
|
||||
}
|
||||
}
|
||||
async fn get_service_port_forward(
|
||||
context: EffectContext,
|
||||
@@ -764,8 +782,8 @@ async fn get_configured(context: EffectContext, _: Empty) -> Result<Value, Error
|
||||
let package = peeked
|
||||
.as_public()
|
||||
.as_package_data()
|
||||
.as_idx(&package_id)
|
||||
.or_not_found(&package_id)?
|
||||
.as_idx(package_id)
|
||||
.or_not_found(package_id)?
|
||||
.as_status()
|
||||
.as_configured()
|
||||
.de()?;
|
||||
@@ -1069,28 +1087,39 @@ enum DependencyKind {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(rename_all = "camelCase", tag = "kind")]
|
||||
#[ts(export)]
|
||||
struct DependencyRequirement {
|
||||
#[ts(type = "string")]
|
||||
id: PackageId,
|
||||
kind: DependencyKind,
|
||||
#[serde(default)]
|
||||
#[ts(type = "string[]")]
|
||||
health_checks: BTreeSet<HealthCheckId>,
|
||||
enum DependencyRequirement {
|
||||
Running {
|
||||
#[ts(type = "string")]
|
||||
id: PackageId,
|
||||
#[ts(type = "string[]")]
|
||||
#[serde(rename = "healthChecks")]
|
||||
health_checks: BTreeSet<HealthCheckId>,
|
||||
#[serde(rename = "versionSpec")]
|
||||
version_spec: String,
|
||||
url: String,
|
||||
},
|
||||
Exists {
|
||||
#[ts(type = "string")]
|
||||
id: PackageId,
|
||||
#[serde(rename = "versionSpec")]
|
||||
version_spec: String,
|
||||
url: String,
|
||||
},
|
||||
}
|
||||
// filebrowser:exists,bitcoind:running:foo+bar+baz
|
||||
impl FromStr for DependencyRequirement {
|
||||
type Err = Error;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.split_once(':') {
|
||||
Some((id, "e")) | Some((id, "exists")) => Ok(Self {
|
||||
Some((id, "e")) | Some((id, "exists")) => Ok(Self::Exists {
|
||||
id: id.parse()?,
|
||||
kind: DependencyKind::Exists,
|
||||
health_checks: BTreeSet::new(),
|
||||
url: "".to_string(),
|
||||
version_spec: "*".to_string(),
|
||||
}),
|
||||
Some((id, rest)) => {
|
||||
let health_checks = match rest.split_once(":") {
|
||||
let health_checks = match rest.split_once(':') {
|
||||
Some(("r", rest)) | Some(("running", rest)) => rest
|
||||
.split('+')
|
||||
.map(|id| id.parse().map_err(Error::from))
|
||||
@@ -1107,16 +1136,18 @@ impl FromStr for DependencyRequirement {
|
||||
)),
|
||||
},
|
||||
}?;
|
||||
Ok(Self {
|
||||
Ok(Self::Running {
|
||||
id: id.parse()?,
|
||||
kind: DependencyKind::Running,
|
||||
health_checks,
|
||||
url: "".to_string(),
|
||||
version_spec: "*".to_string(),
|
||||
})
|
||||
}
|
||||
None => Ok(Self {
|
||||
None => Ok(Self::Running {
|
||||
id: s.parse()?,
|
||||
kind: DependencyKind::Running,
|
||||
health_checks: BTreeSet::new(),
|
||||
url: "".to_string(),
|
||||
version_spec: "*".to_string(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -1148,23 +1179,19 @@ async fn set_dependencies(
|
||||
let dependencies = CurrentDependencies(
|
||||
dependencies
|
||||
.into_iter()
|
||||
.map(
|
||||
|DependencyRequirement {
|
||||
id,
|
||||
kind,
|
||||
health_checks,
|
||||
}| {
|
||||
(
|
||||
id,
|
||||
match kind {
|
||||
DependencyKind::Exists => CurrentDependencyInfo::Exists,
|
||||
DependencyKind::Running => {
|
||||
CurrentDependencyInfo::Running { health_checks }
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
.map(|dependency| match dependency {
|
||||
DependencyRequirement::Exists {
|
||||
id,
|
||||
url,
|
||||
version_spec,
|
||||
} => (id, CurrentDependencyInfo::Exists),
|
||||
DependencyRequirement::Running {
|
||||
id,
|
||||
health_checks,
|
||||
url,
|
||||
version_spec,
|
||||
} => (id, CurrentDependencyInfo::Running { health_checks }),
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
for (dep, entry) in db.as_public_mut().as_package_data_mut().as_entries_mut()? {
|
||||
|
||||
Reference in New Issue
Block a user