Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container/lint: Add --rootfs #1027

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -245,7 +245,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 @@ -1014,13 +1018,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
Loading