Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ composefs-oci = { version = "0.3.0", path = "crates/composefs-oci", default-feat
composefs-boot = { version = "0.3.0", path = "crates/composefs-boot", default-features = false }
composefs-http = { version = "0.3.0", path = "crates/composefs-http", default-features = false }

# JSON-RPC with FD passing for userns helper
jsonrpc-fdpass = { git = "https://github.com/cgwalters/jsonrpc-fdpass", rev = "b30fa1d" }

[profile.dev.package.sha2]
# this is *really* slow otherwise
opt-level = 3
Expand Down
12 changes: 12 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ fmt:
# Run all checks (clippy + fmt + test)
check: clippy fmt-check test

# Run all tests with all features enabled
test-all:
cargo test --workspace --all-features

# Build with containers-storage feature
build-cstorage:
cargo build --workspace --features containers-storage

# Run integration tests (requires podman and skopeo)
integration-test: build-release
cargo run --release -p integration-tests --bin integration-tests

# Clean build artifacts
clean:
cargo clean
5 changes: 4 additions & 1 deletion crates/cfsctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ rust-version.workspace = true
version.workspace = true

[features]
default = ['pre-6.15', 'oci']
default = ['pre-6.15', 'oci', 'containers-storage']
http = ['composefs-http']
oci = ['composefs-oci']
containers-storage = ['composefs-oci/containers-storage', 'cstorage']
rhel9 = ['composefs/rhel9']
'pre-6.15' = ['composefs/pre-6.15']

Expand All @@ -24,8 +25,10 @@ composefs = { workspace = true }
composefs-boot = { workspace = true }
composefs-oci = { workspace = true, optional = true }
composefs-http = { workspace = true, optional = true }
cstorage = { path = "../cstorage", features = ["userns-helper"], optional = true }
env_logger = { version = "0.11.0", default-features = false }
hex = { version = "0.4.0", default-features = false }
indicatif = { version = "0.17.0", default-features = false }
rustix = { version = "1.0.0", default-features = false, features = ["fs", "process"] }
tokio = { version = "1.24.2", default-features = false }

Expand Down
52 changes: 46 additions & 6 deletions crates/cfsctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,20 @@ where
Ok(repo)
}

#[tokio::main]
async fn main() -> Result<()> {
fn main() -> Result<()> {
// If we were spawned as a userns helper process, handle that and exit.
// This MUST be called before the tokio runtime is created.
#[cfg(feature = "containers-storage")]
cstorage::init_if_helper();

// Now we can create the tokio runtime for the main application
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(async_main())
}

async fn async_main() -> Result<()> {
env_logger::init();

let args = App::parse();
Expand Down Expand Up @@ -298,11 +310,39 @@ where
println!("{}", image_id.to_id());
}
OciCommand::Pull { ref image, name } => {
let (digest, verity) =
composefs_oci::pull(&Arc::new(repo), image, name.as_deref(), None).await?;
let repo = Arc::new(repo);
let result = composefs_oci::pull(&repo, image, name.as_deref(), None).await?;

println!("config {digest}");
println!("verity {}", verity.to_hex());
println!("config {}", result.config_digest);
println!("verity {}", result.config_verity.to_hex());

// Print import statistics if available (containers-storage imports)
#[cfg(feature = "containers-storage")]
if let Some(stats) = result.stats {
println!();
println!("Import statistics:");
println!(
" layers: {} ({} already present)",
stats.layers, stats.layers_already_present
);
println!(
" objects: {} total ({} reflinked, {} copied, {} already present)",
stats.total_objects(),
stats.objects_reflinked,
stats.objects_copied,
stats.objects_already_present
);
if stats.used_reflinks() {
println!(
" reflinked: {} (zero-copy)",
indicatif::HumanBytes(stats.bytes_reflinked)
);
}
if stats.bytes_copied > 0 {
println!(" copied: {}", indicatif::HumanBytes(stats.bytes_copied));
}
println!(" inlined: {}", indicatif::HumanBytes(stats.bytes_inlined));
}
}
OciCommand::Seal {
ref config_name,
Expand Down
10 changes: 9 additions & 1 deletion crates/composefs-oci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,33 @@ repository.workspace = true
rust-version.workspace = true
version.workspace = true

[features]
default = ["containers-storage"]
containers-storage = ["dep:cstorage", "cstorage?/userns-helper"]

[dependencies]
anyhow = { version = "1.0.87", default-features = false }
async-compression = { version = "0.4.0", default-features = false, features = ["tokio", "zstd", "gzip"] }
base64 = { version = "0.22", default-features = false, features = ["std"] }
bytes = { version = "1", default-features = false }
composefs = { workspace = true }
containers-image-proxy = { version = "0.9.2", default-features = false }
cstorage = { path = "../cstorage", optional = true }
hex = { version = "0.4.0", default-features = false }
indicatif = { version = "0.17.0", default-features = false, features = ["tokio"] }
oci-spec = { version = "0.8.0", default-features = false }
rustix = { version = "1.0.0", features = ["fs"] }
sha2 = { version = "0.10.1", default-features = false }
tar = { version = "0.4.38", default-features = false }
tar-header = { path = "../tar-header" }
tokio = { version = "1.24.2", features = ["rt-multi-thread"] }
tokio-util = { version = "0.7", default-features = false, features = ["io"] }

[dev-dependencies]
similar-asserts = "1.7.0"
composefs = { workspace = true, features = ["test"] }
once_cell = "1.21.3"
proptest = "1"
similar-asserts = "1.7.0"
tempfile = "3.8.0"

[lints]
Expand Down
Loading
Loading