mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +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()
|
||||
))
|
||||
.await?;
|
||||
let docker = Docker::connect_with_unix_defaults()?;
|
||||
let net_controller = Arc::new(
|
||||
NetController::init(
|
||||
base.tor_control
|
||||
@@ -75,7 +76,8 @@ impl RpcContext {
|
||||
let managers = ManagerMap::init(
|
||||
&mut db.handle(),
|
||||
&mut secret_store.acquire().await?,
|
||||
&*net_controller,
|
||||
docker.clone(),
|
||||
net_controller.clone(),
|
||||
)
|
||||
.await?;
|
||||
let seed = Arc::new(RpcContextSeed {
|
||||
@@ -83,7 +85,7 @@ impl RpcContext {
|
||||
bind_ws: base.bind_ws.unwrap_or(([127, 0, 0, 1], 5960).into()),
|
||||
db,
|
||||
secret_store,
|
||||
docker: Docker::connect_with_unix_defaults()?,
|
||||
docker,
|
||||
net_controller,
|
||||
managers,
|
||||
});
|
||||
|
||||
@@ -355,7 +355,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
.await?;
|
||||
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?;
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ pub struct InstallProgress {
|
||||
pub download_complete: AtomicBool,
|
||||
pub validated: AtomicU64,
|
||||
pub validation_complete: AtomicBool,
|
||||
pub read: AtomicU64,
|
||||
pub read_complete: AtomicBool,
|
||||
pub unpacked: AtomicU64,
|
||||
pub unpack_complete: AtomicBool,
|
||||
}
|
||||
impl InstallProgress {
|
||||
pub fn new(size: Option<u64>) -> Arc<Self> {
|
||||
@@ -32,8 +32,8 @@ impl InstallProgress {
|
||||
download_complete: AtomicBool::new(false),
|
||||
validated: AtomicU64::new(0),
|
||||
validation_complete: AtomicBool::new(false),
|
||||
read: AtomicU64::new(0),
|
||||
read_complete: AtomicBool::new(false),
|
||||
unpacked: AtomicU64::new(0),
|
||||
unpack_complete: AtomicBool::new(false),
|
||||
})
|
||||
}
|
||||
pub fn download_complete(&self) {
|
||||
@@ -182,7 +182,7 @@ impl<R: AsyncRead> AsyncRead for InstallProgressTracker<R> {
|
||||
if *this.validating {
|
||||
&this.progress.validated
|
||||
} else {
|
||||
&this.progress.read
|
||||
&this.progress.unpacked
|
||||
}
|
||||
.fetch_add(buf.filled().len() as u64 - prev, Ordering::SeqCst);
|
||||
|
||||
@@ -204,7 +204,7 @@ impl<R: AsyncSeek> AsyncSeek for InstallProgressTracker<R> {
|
||||
if *this.validating {
|
||||
&this.progress.validated
|
||||
} else {
|
||||
&this.progress.read
|
||||
&this.progress.unpacked
|
||||
}
|
||||
.store(n, Ordering::SeqCst);
|
||||
Poll::Ready(Ok(n))
|
||||
|
||||
@@ -28,11 +28,21 @@ impl ManagerMap {
|
||||
pub async fn init<Db: DbHandle, Ex>(
|
||||
db: &mut Db,
|
||||
secrets: &mut Ex,
|
||||
net_ctl: &NetController,
|
||||
docker: Docker,
|
||||
net_ctl: Arc<NetController>,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
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!()
|
||||
}
|
||||
|
||||
@@ -114,7 +124,7 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
||||
)
|
||||
.await
|
||||
});
|
||||
let mut ip = None::<Ipv4Addr>;
|
||||
let mut ip;
|
||||
loop {
|
||||
match state
|
||||
.docker
|
||||
@@ -137,7 +147,7 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
||||
match futures::poll!(&mut runtime) {
|
||||
Poll::Ready(res) => {
|
||||
return res
|
||||
.map_err(|e| {
|
||||
.map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("Manager runtime panicked!"),
|
||||
crate::ErrorKind::Docker,
|
||||
@@ -186,17 +196,20 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
||||
.await?;
|
||||
let res = runtime
|
||||
.await
|
||||
.map_err(|e| {
|
||||
.map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("Manager runtime panicked!"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})
|
||||
.and_then(|a| a);
|
||||
state.net_ctl.remove(
|
||||
&state.manifest.id,
|
||||
state.manifest.interfaces.0.keys().cloned(),
|
||||
);
|
||||
state
|
||||
.net_ctl
|
||||
.remove(
|
||||
&state.manifest.id,
|
||||
state.manifest.interfaces.0.keys().cloned(),
|
||||
)
|
||||
.await?;
|
||||
res
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,12 @@ pub fn pack(#[context] ctx: EitherContext, #[arg] path: Option<PathBuf>) -> Resu
|
||||
let mut s = String::new();
|
||||
File::open(path.join("manifest.toml"))?.read_to_string(&mut s)?;
|
||||
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 {
|
||||
return Err(Error::new(
|
||||
anyhow!("manifest not found"),
|
||||
|
||||
Reference in New Issue
Block a user