diff --git a/docs/bootc-images.md b/docs/bootc-images.md index 8a3355634..afa1470c3 100644 --- a/docs/bootc-images.md +++ b/docs/bootc-images.md @@ -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 diff --git a/lib/src/cli.rs b/lib/src/cli.rs index da4441bab..77154fcb7 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -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}"); diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index 6b4373983..df53779e0 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -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"; @@ -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( @@ -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; } diff --git a/lib/src/lib.rs b/lib/src/lib.rs index fafdd991e..9bb1ac3d2 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -20,6 +20,7 @@ pub mod cli; pub(crate) mod deploy; mod lsm; +pub(crate) mod metadata; mod reboot; mod reexec; mod status; diff --git a/lib/src/metadata.rs b/lib/src/metadata.rs new file mode 100644 index 000000000..4db5758bf --- /dev/null +++ b/lib/src/metadata.rs @@ -0,0 +1,4 @@ +/// This label is expected to be present on compatible base images. +pub(crate) const BOOTC_COMPAT_LABEL: &str = "containers.bootc"; +/// The current single well-known value for the label. +pub(crate) const COMPAT_LABEL_V1: &str = "1";