mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 22:39:46 +00:00
add support for yaml and json manifests
This commit is contained in:
committed by
Aiden McClelland
parent
a14820087d
commit
48c33be14c
@@ -65,6 +65,7 @@ impl RpcContext {
|
|||||||
.display()
|
.display()
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
|
let docker = Docker::connect_with_unix_defaults()?;
|
||||||
let net_controller = Arc::new(
|
let net_controller = Arc::new(
|
||||||
NetController::init(
|
NetController::init(
|
||||||
base.tor_control
|
base.tor_control
|
||||||
@@ -75,7 +76,8 @@ impl RpcContext {
|
|||||||
let managers = ManagerMap::init(
|
let managers = ManagerMap::init(
|
||||||
&mut db.handle(),
|
&mut db.handle(),
|
||||||
&mut secret_store.acquire().await?,
|
&mut secret_store.acquire().await?,
|
||||||
&*net_controller,
|
docker.clone(),
|
||||||
|
net_controller.clone(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let seed = Arc::new(RpcContextSeed {
|
let seed = Arc::new(RpcContextSeed {
|
||||||
@@ -83,7 +85,7 @@ impl RpcContext {
|
|||||||
bind_ws: base.bind_ws.unwrap_or(([127, 0, 0, 1], 5960).into()),
|
bind_ws: base.bind_ws.unwrap_or(([127, 0, 0, 1], 5960).into()),
|
||||||
db,
|
db,
|
||||||
secret_store,
|
secret_store,
|
||||||
docker: Docker::connect_with_unix_defaults()?,
|
docker,
|
||||||
net_controller,
|
net_controller,
|
||||||
managers,
|
managers,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
|||||||
.await?;
|
.await?;
|
||||||
log::info!("Install {}@{}: Unpacked Docker Images", pkg_id, version,);
|
log::info!("Install {}@{}: Unpacked Docker Images", pkg_id, version,);
|
||||||
|
|
||||||
progress.read_complete.store(true, Ordering::SeqCst);
|
progress.unpack_complete.store(true, Ordering::SeqCst);
|
||||||
|
|
||||||
progress_model.put(&mut ctx.db.handle(), &progress).await?;
|
progress_model.put(&mut ctx.db.handle(), &progress).await?;
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ pub struct InstallProgress {
|
|||||||
pub download_complete: AtomicBool,
|
pub download_complete: AtomicBool,
|
||||||
pub validated: AtomicU64,
|
pub validated: AtomicU64,
|
||||||
pub validation_complete: AtomicBool,
|
pub validation_complete: AtomicBool,
|
||||||
pub read: AtomicU64,
|
pub unpacked: AtomicU64,
|
||||||
pub read_complete: AtomicBool,
|
pub unpack_complete: AtomicBool,
|
||||||
}
|
}
|
||||||
impl InstallProgress {
|
impl InstallProgress {
|
||||||
pub fn new(size: Option<u64>) -> Arc<Self> {
|
pub fn new(size: Option<u64>) -> Arc<Self> {
|
||||||
@@ -32,8 +32,8 @@ impl InstallProgress {
|
|||||||
download_complete: AtomicBool::new(false),
|
download_complete: AtomicBool::new(false),
|
||||||
validated: AtomicU64::new(0),
|
validated: AtomicU64::new(0),
|
||||||
validation_complete: AtomicBool::new(false),
|
validation_complete: AtomicBool::new(false),
|
||||||
read: AtomicU64::new(0),
|
unpacked: AtomicU64::new(0),
|
||||||
read_complete: AtomicBool::new(false),
|
unpack_complete: AtomicBool::new(false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn download_complete(&self) {
|
pub fn download_complete(&self) {
|
||||||
@@ -182,7 +182,7 @@ impl<R: AsyncRead> AsyncRead for InstallProgressTracker<R> {
|
|||||||
if *this.validating {
|
if *this.validating {
|
||||||
&this.progress.validated
|
&this.progress.validated
|
||||||
} else {
|
} else {
|
||||||
&this.progress.read
|
&this.progress.unpacked
|
||||||
}
|
}
|
||||||
.fetch_add(buf.filled().len() as u64 - prev, Ordering::SeqCst);
|
.fetch_add(buf.filled().len() as u64 - prev, Ordering::SeqCst);
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ impl<R: AsyncSeek> AsyncSeek for InstallProgressTracker<R> {
|
|||||||
if *this.validating {
|
if *this.validating {
|
||||||
&this.progress.validated
|
&this.progress.validated
|
||||||
} else {
|
} else {
|
||||||
&this.progress.read
|
&this.progress.unpacked
|
||||||
}
|
}
|
||||||
.store(n, Ordering::SeqCst);
|
.store(n, Ordering::SeqCst);
|
||||||
Poll::Ready(Ok(n))
|
Poll::Ready(Ok(n))
|
||||||
|
|||||||
@@ -28,11 +28,21 @@ impl ManagerMap {
|
|||||||
pub async fn init<Db: DbHandle, Ex>(
|
pub async fn init<Db: DbHandle, Ex>(
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
secrets: &mut Ex,
|
secrets: &mut Ex,
|
||||||
net_ctl: &NetController,
|
docker: Docker,
|
||||||
|
net_ctl: Arc<NetController>,
|
||||||
) -> Result<Self, Error>
|
) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
for<'a> &'a mut Ex: Executor<'a, Database = Sqlite>,
|
for<'a> &'a mut Ex: Executor<'a, Database = Sqlite>,
|
||||||
{
|
{
|
||||||
|
// let mut res = ManagerMap(RwLock::new(HashMap::new()));
|
||||||
|
// for package in crate::db::DatabaseModel::new()
|
||||||
|
// .package_data()
|
||||||
|
// .keys(db, true)
|
||||||
|
// .await?
|
||||||
|
// {
|
||||||
|
// let man = crate::db::DatabaseModel::new().package_data().idx_model(&package).
|
||||||
|
// res.add(docker.clone(), net_ctl.clone(), manifest, tor_keys)
|
||||||
|
// }
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +124,7 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
});
|
});
|
||||||
let mut ip = None::<Ipv4Addr>;
|
let mut ip;
|
||||||
loop {
|
loop {
|
||||||
match state
|
match state
|
||||||
.docker
|
.docker
|
||||||
@@ -137,7 +147,7 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
|||||||
match futures::poll!(&mut runtime) {
|
match futures::poll!(&mut runtime) {
|
||||||
Poll::Ready(res) => {
|
Poll::Ready(res) => {
|
||||||
return res
|
return res
|
||||||
.map_err(|e| {
|
.map_err(|_| {
|
||||||
Error::new(
|
Error::new(
|
||||||
anyhow!("Manager runtime panicked!"),
|
anyhow!("Manager runtime panicked!"),
|
||||||
crate::ErrorKind::Docker,
|
crate::ErrorKind::Docker,
|
||||||
@@ -186,17 +196,20 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
|||||||
.await?;
|
.await?;
|
||||||
let res = runtime
|
let res = runtime
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|_| {
|
||||||
Error::new(
|
Error::new(
|
||||||
anyhow!("Manager runtime panicked!"),
|
anyhow!("Manager runtime panicked!"),
|
||||||
crate::ErrorKind::Docker,
|
crate::ErrorKind::Docker,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.and_then(|a| a);
|
.and_then(|a| a);
|
||||||
state.net_ctl.remove(
|
state
|
||||||
&state.manifest.id,
|
.net_ctl
|
||||||
state.manifest.interfaces.0.keys().cloned(),
|
.remove(
|
||||||
);
|
&state.manifest.id,
|
||||||
|
state.manifest.interfaces.0.keys().cloned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ pub fn pack(#[context] ctx: EitherContext, #[arg] path: Option<PathBuf>) -> Resu
|
|||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
File::open(path.join("manifest.toml"))?.read_to_string(&mut s)?;
|
File::open(path.join("manifest.toml"))?.read_to_string(&mut s)?;
|
||||||
serde_toml::from_str(&s).with_kind(crate::ErrorKind::Deserialization)?
|
serde_toml::from_str(&s).with_kind(crate::ErrorKind::Deserialization)?
|
||||||
|
} else if path.join("manifest.yaml").exists() {
|
||||||
|
serde_yaml::from_reader(File::open(path.join("manifest.yaml"))?)
|
||||||
|
.with_kind(crate::ErrorKind::Deserialization)?
|
||||||
|
} else if path.join("manifest.json").exists() {
|
||||||
|
serde_json::from_reader(File::open(path.join("manifest.json"))?)
|
||||||
|
.with_kind(crate::ErrorKind::Deserialization)?
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::new(
|
return Err(Error::new(
|
||||||
anyhow!("manifest not found"),
|
anyhow!("manifest not found"),
|
||||||
|
|||||||
Reference in New Issue
Block a user