Skip to content

Commit 1ae8ee8

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 862ab95 commit 1ae8ee8

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
@@ -13,7 +13,7 @@ version.workspace = true
1313
[features]
1414
default = ['pre-6.15', 'oci']
1515
http = ['composefs-http']
16-
oci = ['composefs-oci']
16+
oci = ['composefs-oci', 'splitfdstream']
1717
rhel9 = ['composefs/rhel9']
1818
'pre-6.15' = ['composefs/pre-6.15']
1919

@@ -25,6 +25,7 @@ composefs = { workspace = true }
2525
composefs-boot = { workspace = true }
2626
composefs-oci = { workspace = true, optional = true }
2727
composefs-http = { workspace = true, optional = true }
28+
splitfdstream = { workspace = true, optional = true }
2829
env_logger = { version = "0.11.0", default-features = false }
2930
hex = { version = "0.4.0", default-features = false }
3031
rustix = { version = "1.0.0", default-features = false, features = ["fs", "process"] }

crates/cfsctl/src/main.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ enum OciCommand {
8484
digest: String,
8585
name: Option<String>,
8686
},
87+
/// Imports a complete image from a splitfdstream server into the repository.
88+
ImportImageSplitfdstream {
89+
/// Path to the splitfdstream server socket
90+
socket: PathBuf,
91+
/// The image ID (manifest digest or tag)
92+
image_id: String,
93+
/// Tag name for imported image
94+
#[clap(long)]
95+
tag: Option<String>,
96+
},
8797
/// Lists the contents of a tar stream
8898
LsLayer {
8999
/// the name of the stream to list, either a stream ID in format oci-config-<hash_type>:<hash_digest> or a reference in 'ref/'
@@ -316,6 +326,27 @@ where
316326
)?;
317327
println!("{}", object_id.to_id());
318328
}
329+
OciCommand::ImportImageSplitfdstream {
330+
socket,
331+
image_id,
332+
tag,
333+
} => {
334+
let result = composefs_oci::import_complete_image_from_splitfdstream(
335+
&Arc::new(repo),
336+
&socket,
337+
&image_id,
338+
tag.as_deref(),
339+
)?;
340+
341+
println!("Imported complete image:");
342+
println!(" Manifest: {}", result.manifest_digest);
343+
println!(" Config: {}", result.config_digest);
344+
println!(" Layers: {}", result.layers_imported);
345+
println!(" Size: {} bytes", result.total_size_bytes);
346+
if let Some(tag_name) = tag {
347+
println!(" Tagged: {}", tag_name);
348+
}
349+
}
319350
OciCommand::LsLayer { name } => {
320351
composefs_oci::ls_layer(&repo, &name)?;
321352
}

0 commit comments

Comments
 (0)