Skip to content

Commit 4f80ec6

Browse files
committed
new command import-layer-splitfdstream
Add a client library for communicating with the containers-storage splitfdstream server. This enables importing OCI container layers via UNIX socket with file descriptor passing. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 9469b58 commit 4f80ec6

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ composefs = { version = "0.3.0", path = "crates/composefs", default-features = f
2020
composefs-oci = { version = "0.3.0", path = "crates/composefs-oci", default-features = false }
2121
composefs-boot = { version = "0.3.0", path = "crates/composefs-boot", default-features = false }
2222
composefs-http = { version = "0.3.0", path = "crates/composefs-http", default-features = false }
23+
splitfdstream = { version = "0.3.0", path = "crates/splitfdstream", default-features = false }
2324

2425
[profile.dev.package.sha2]
2526
# this is *really* slow otherwise

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ enum OciCommand {
8484
digest: String,
8585
name: Option<String>,
8686
},
87+
/// Imports a layer from a splitfdstream server into the repository.
88+
ImportLayerSplitfdstream {
89+
/// Path to the splitfdstream server socket
90+
socket: PathBuf,
91+
/// The layer digest (e.g., sha256:abc123...)
92+
digest: String,
93+
/// Optional reference name for the layer
94+
name: Option<String>,
95+
/// Layer ID to request from splitfdstream server (defaults to digest)
96+
#[clap(long)]
97+
layer_id: Option<String>,
98+
/// Parent layer ID for delta computation
99+
#[clap(long)]
100+
parent_id: Option<String>,
101+
},
87102
/// Lists the contents of a tar stream
88103
LsLayer {
89104
/// the name of the stream to list, either a stream ID in format oci-config-<hash_type>:<hash_digest> or a reference in 'ref/'
@@ -295,6 +310,23 @@ where
295310
)?;
296311
println!("{}", object_id.to_id());
297312
}
313+
OciCommand::ImportLayerSplitfdstream {
314+
socket,
315+
digest,
316+
name,
317+
layer_id,
318+
parent_id,
319+
} => {
320+
let object_id = composefs_oci::import_from_splitfdstream(
321+
&Arc::new(repo),
322+
&socket,
323+
&digest,
324+
layer_id.as_deref(),
325+
parent_id.as_deref(),
326+
name.as_deref(),
327+
)?;
328+
println!("{}", object_id.to_id());
329+
}
298330
OciCommand::LsLayer { name } => {
299331
composefs_oci::ls_layer(&repo, &name)?;
300332
}

0 commit comments

Comments
 (0)