Skip to content

Commit d2fd4ef

Browse files
committed
cfsctl: add import-image-splitfdstream command
Add a CLI subcommand to import a complete OCI image from a containers-storage splitfdstream server over a UNIX socket. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 7552751 commit d2fd4ef

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

crates/cfsctl/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ path = "src/lib.rs"
1616
[features]
1717
default = ['pre-6.15', 'oci']
1818
http = ['composefs-http']
19-
oci = ['composefs-oci']
19+
oci = ['composefs-oci', 'splitfdstream']
2020
rhel9 = ['composefs/rhel9']
2121
'pre-6.15' = ['composefs/pre-6.15']
2222

@@ -29,6 +29,7 @@ composefs = { workspace = true }
2929
composefs-boot = { workspace = true }
3030
composefs-oci = { workspace = true, optional = true }
3131
composefs-http = { workspace = true, optional = true }
32+
splitfdstream = { workspace = true, optional = true }
3233
env_logger = { version = "0.11.0", default-features = false }
3334
hex = { version = "0.4.0", default-features = false }
3435
rustix = { version = "1.0.0", default-features = false, features = ["fs", "process"] }

crates/cfsctl/src/lib.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ enum OciCommand {
8686
digest: String,
8787
name: Option<String>,
8888
},
89+
/// Imports a complete image from a splitfdstream server into the repository.
90+
ImportImageSplitfdstream {
91+
/// Path to the splitfdstream server socket
92+
socket: PathBuf,
93+
/// The image ID (manifest digest or tag)
94+
image_id: String,
95+
/// Tag name for imported image
96+
#[clap(long)]
97+
tag: Option<String>,
98+
},
8999
/// Lists the contents of a tar stream
90100
LsLayer {
91101
/// the name of the stream to list, either a stream ID in format oci-config-<hash_type>:<hash_digest> or a reference in 'ref/'
@@ -356,6 +366,27 @@ where
356366
)?;
357367
println!("{}", object_id.to_id());
358368
}
369+
OciCommand::ImportImageSplitfdstream {
370+
socket,
371+
image_id,
372+
tag,
373+
} => {
374+
let result = composefs_oci::import_complete_image_from_splitfdstream(
375+
&Arc::new(repo),
376+
&socket,
377+
&image_id,
378+
tag.as_deref(),
379+
)?;
380+
381+
println!("Imported complete image:");
382+
println!(" Manifest: {}", result.manifest_digest);
383+
println!(" Config: {}", result.config_digest);
384+
println!(" Layers: {}", result.layers_imported);
385+
println!(" Size: {} bytes", result.total_size_bytes);
386+
if let Some(tag_name) = tag {
387+
println!(" Tagged: {}", tag_name);
388+
}
389+
}
359390
OciCommand::LsLayer { name } => {
360391
composefs_oci::ls_layer(&repo, &name)?;
361392
}

0 commit comments

Comments
 (0)