Skip to content

Commit

Permalink
Merge pull request #1027 from cgwalters/lint-altroot
Browse files Browse the repository at this point in the history
container/lint: Add --rootfs
  • Loading branch information
cgwalters authored Jan 15, 2025
2 parents 0767f7d + c00adee commit dc7d4cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion docs/src/man/bootc-container-lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ checks as part of a container build

# SYNOPSIS

**bootc container lint** \[**-h**\|**\--help**\]
**bootc container lint** \[**\--rootfs**\] \[**-h**\|**\--help**\]

# DESCRIPTION

Expand All @@ -17,6 +17,10 @@ part of a build process; it will error if any problems are detected.

# OPTIONS

**\--rootfs**=*ROOTFS* \[default: /\]

: Operate on the provided rootfs

**-h**, **\--help**

: Print help (see a summary with -h)
Expand Down
10 changes: 7 additions & 3 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ pub(crate) enum ContainerOpts {
///
/// This is intended to be invoked via e.g. `RUN bootc container lint` as part
/// of a build process; it will error if any problems are detected.
Lint,
Lint {
/// Operate on the provided rootfs.
#[clap(long, default_value = "/")]
rootfs: Utf8PathBuf,
},
}

/// Subcommands which operate on images.
Expand Down Expand Up @@ -1007,13 +1011,13 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
Opt::Edit(opts) => edit(opts).await,
Opt::UsrOverlay => usroverlay().await,
Opt::Container(opts) => match opts {
ContainerOpts::Lint => {
ContainerOpts::Lint { rootfs } => {
if !ostree_ext::container_utils::is_ostree_container()? {
anyhow::bail!(
"Not in a ostree container, this command only verifies ostree containers."
);
}

let root = &Dir::open_ambient_dir(rootfs, cap_std::ambient_authority())?;
lints::lint(root)?;
Ok(())
}
Expand Down

0 comments on commit dc7d4cf

Please sign in to comment.