mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-06 22:51:31 +00:00
chore: rework oci crate to be more composable
This commit is contained in:
@ -3,11 +3,10 @@ use std::{env::args, path::PathBuf};
|
||||
use anyhow::Result;
|
||||
use env_logger::Env;
|
||||
use krataoci::{
|
||||
cache::ImageCache,
|
||||
compiler::OciImageCompiler,
|
||||
name::ImageName,
|
||||
packer::OciPackerFormat,
|
||||
packer::{service::OciPackerService, OciPackedFormat},
|
||||
progress::{OciProgress, OciProgressContext},
|
||||
registry::OciPlatform,
|
||||
};
|
||||
use tokio::{fs, sync::broadcast};
|
||||
|
||||
@ -23,8 +22,6 @@ async fn main() -> Result<()> {
|
||||
fs::create_dir(&cache_dir).await?;
|
||||
}
|
||||
|
||||
let cache = ImageCache::new(&cache_dir)?;
|
||||
|
||||
let (sender, mut receiver) = broadcast::channel::<OciProgress>(1000);
|
||||
tokio::task::spawn(async move {
|
||||
loop {
|
||||
@ -41,14 +38,14 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
});
|
||||
let context = OciProgressContext::new(sender);
|
||||
let compiler = OciImageCompiler::new(&cache, seed, context)?;
|
||||
let info = compiler
|
||||
.compile(&image.to_string(), &image, OciPackerFormat::Squashfs)
|
||||
let service = OciPackerService::new(seed, &cache_dir, OciPlatform::current(), context)?;
|
||||
let packed = service
|
||||
.pack("cli", image.clone(), OciPackedFormat::Squashfs)
|
||||
.await?;
|
||||
println!(
|
||||
"generated squashfs of {} to {}",
|
||||
image,
|
||||
info.image.to_string_lossy()
|
||||
packed.path.to_string_lossy()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user