Skip to content

Commit

Permalink
Add suggestion for LABEL containers.bootc 1
Browse files Browse the repository at this point in the history
As we aim to slowly move away from ostree, let's add a bootc label
that we expect to be used.  For now, this is just a warning.

I will change rpm-ostree to add this by default if we take this.

But this one is also an important step for if we ever add the
flow of simply deriving from an existing application base image.

Signed-off-by: Colin Walters <walters@verbum.org>
  • Loading branch information
cgwalters committed Feb 2, 2024
1 parent 8558c96 commit 8244d76
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/bootc-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ The requirement for both methods is that your initial treefile/manifest
However, the ostree usage is an implementation detail
and the requirement on this will be lifted in the future.

## Standard metadata for bootc compatible images

It is strongly recommended to do:

```dockerfile
LABEL containers.bootc 1
```

This will signal that this image is intended to be usable with `bootc`.

# Deriving from existing base images

It's important to emphasize that from one
Expand Down
1 change: 1 addition & 0 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
println!("No changes in: {}", imgref);
}
PrepareResult::Ready(r) => {
crate::deploy::check_bootc_label(&r.config);
println!("Update available for: {}", imgref);
if let Some(version) = r.version() {
println!(" Version: {version}");
Expand Down
22 changes: 22 additions & 0 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use ostree_ext::sysroot::SysrootLock;

use crate::spec::HostSpec;
use crate::spec::ImageReference;
use crate::status::labels_of_config;

// TODO use https://github.com/ostreedev/ostree-rs-ext/pull/493/commits/afc1837ff383681b947de30c0cefc70080a4f87a
const BASE_IMAGE_PREFIX: &str = "ostree/container/baseimage/bootc";
Expand Down Expand Up @@ -84,6 +85,26 @@ pub(crate) async fn new_importer(
Ok(imp)
}

pub(crate) fn check_bootc_label(config: &ostree_ext::oci_spec::image::ImageConfiguration) {
if let Some(label) =
labels_of_config(config).and_then(|labels| labels.get(crate::metadata::BOOTC_COMPAT_LABEL))
{
match label.as_str() {
crate::metadata::COMPAT_LABEL_V1 => {}
o => eprintln!(
"notice: Unknown {} value {}",
crate::metadata::BOOTC_COMPAT_LABEL,
o
),
}
} else {
eprintln!(
"notice: Image is missing label: {}",
crate::metadata::BOOTC_COMPAT_LABEL
)
}
}

/// Wrapper for pulling a container image, wiring up status output.
#[context("Pulling")]
pub(crate) async fn pull(
Expand All @@ -101,6 +122,7 @@ pub(crate) async fn pull(
}
PrepareResult::Ready(p) => p,
};
check_bootc_label(&prep.config);
if let Some(warning) = prep.deprecated_warning() {
ostree_ext::cli::print_deprecated_warning(warning).await;
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
pub mod cli;
pub(crate) mod deploy;
mod lsm;
pub(crate) mod metadata;
mod reboot;
mod reexec;
mod status;
Expand Down

0 comments on commit 8244d76

Please sign in to comment.