Skip to content

Commit a8356de

Browse files
committed
cli: Wrap ostree-ext via bootc internals
Today rpm-ostree exposes the `ostree container` verb. As part of taking over from rpm-ostree we need to do the same. Followup to merging ostree-rs-ext in this repository. A next step here is for us to start owning the /usr/libexec/libostree/ext/ostree-container symlink but that will be a followup. Signed-off-by: Colin Walters <[email protected]>
1 parent affc8b9 commit a8356de

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

lib/src/cli.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ pub(crate) enum InternalsOpts {
295295
PrintJsonSchema,
296296
/// Perform cleanup actions
297297
Cleanup,
298+
/// Proxy frontend for the `ostree-ext` CLI.
299+
OstreeExt {
300+
#[clap(allow_hyphen_values = true)]
301+
args: Vec<OsString>,
302+
},
303+
/// Proxy frontend for the legacy `ostree container` CLI.
304+
OstreeContainer {
305+
#[clap(allow_hyphen_values = true)]
306+
args: Vec<OsString>,
307+
},
298308
}
299309

300310
#[derive(Debug, clap::Subcommand, PartialEq, Eq)]
@@ -931,6 +941,17 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
931941
let unit_dir = &Dir::open_ambient_dir(normal_dir, cap_std::ambient_authority())?;
932942
crate::generator::generator(root, unit_dir)
933943
}
944+
InternalsOpts::OstreeExt { args } => {
945+
ostree_ext::cli::run_from_iter(["ostree-ext".into()].into_iter().chain(args)).await
946+
}
947+
InternalsOpts::OstreeContainer { args } => {
948+
ostree_ext::cli::run_from_iter(
949+
["ostree-ext".into(), "container".into()]
950+
.into_iter()
951+
.chain(args),
952+
)
953+
.await
954+
}
934955
InternalsOpts::FixupEtcFstab => crate::deploy::fixup_etc_fstab(&root),
935956
InternalsOpts::PrintJsonSchema => {
936957
let schema = schema_for!(crate::spec::Host);
@@ -1005,3 +1026,11 @@ fn test_parse_generator() {
10051026
Opt::Internals(InternalsOpts::SystemdGenerator { .. })
10061027
));
10071028
}
1029+
1030+
#[test]
1031+
fn test_parse_ostree_ext() {
1032+
assert!(matches!(
1033+
Opt::parse_including_static(["bootc", "internals", "ostree-container"]),
1034+
Opt::Internals(InternalsOpts::OstreeContainer { .. })
1035+
));
1036+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Verify our wrapped "bootc internals ostree-container" calling into
2+
# the legacy ostree-ext CLI.
3+
use std assert
4+
use tap.nu
5+
6+
tap begin "verify bootc wrapping ostree-ext"
7+
8+
# Parse the status and get the booted image
9+
let st = bootc status --json | from json
10+
let booted = $st.status.booted.image
11+
# Then verify we can extract its metadata via the ostree-container code.
12+
let metadata = bootc internals ostree-container image metadata --repo=/ostree/repo $"($booted.image.transport):($booted.image.image)" | from json
13+
assert equal $metadata.mediaType "application/vnd.oci.image.manifest.v1+json"

0 commit comments

Comments
 (0)