Skip to content

Commit

Permalink
cli: Wrap ostree-ext via bootc internals
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
cgwalters committed Nov 8, 2024
1 parent affc8b9 commit a8356de
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ pub(crate) enum InternalsOpts {
PrintJsonSchema,
/// Perform cleanup actions
Cleanup,
/// Proxy frontend for the `ostree-ext` CLI.
OstreeExt {
#[clap(allow_hyphen_values = true)]
args: Vec<OsString>,
},
/// Proxy frontend for the legacy `ostree container` CLI.
OstreeContainer {
#[clap(allow_hyphen_values = true)]
args: Vec<OsString>,
},
}

#[derive(Debug, clap::Subcommand, PartialEq, Eq)]
Expand Down Expand Up @@ -931,6 +941,17 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
let unit_dir = &Dir::open_ambient_dir(normal_dir, cap_std::ambient_authority())?;
crate::generator::generator(root, unit_dir)
}
InternalsOpts::OstreeExt { args } => {
ostree_ext::cli::run_from_iter(["ostree-ext".into()].into_iter().chain(args)).await
}
InternalsOpts::OstreeContainer { args } => {
ostree_ext::cli::run_from_iter(
["ostree-ext".into(), "container".into()]
.into_iter()
.chain(args),
)
.await
}
InternalsOpts::FixupEtcFstab => crate::deploy::fixup_etc_fstab(&root),
InternalsOpts::PrintJsonSchema => {
let schema = schema_for!(crate::spec::Host);
Expand Down Expand Up @@ -1005,3 +1026,11 @@ fn test_parse_generator() {
Opt::Internals(InternalsOpts::SystemdGenerator { .. })
));
}

#[test]
fn test_parse_ostree_ext() {
assert!(matches!(
Opt::parse_including_static(["bootc", "internals", "ostree-container"]),
Opt::Internals(InternalsOpts::OstreeContainer { .. })
));
}
13 changes: 13 additions & 0 deletions tests/booted/readonly/11-ostree-ext-cli.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Verify our wrapped "bootc internals ostree-container" calling into
# the legacy ostree-ext CLI.
use std assert
use tap.nu

tap begin "verify bootc wrapping ostree-ext"

# Parse the status and get the booted image
let st = bootc status --json | from json
let booted = $st.status.booted.image
# Then verify we can extract its metadata via the ostree-container code.
let metadata = bootc internals ostree-container image metadata --repo=/ostree/repo $"($booted.image.transport):($booted.image.image)" | from json
assert equal $metadata.mediaType "application/vnd.oci.image.manifest.v1+json"

0 comments on commit a8356de

Please sign in to comment.