Skip to content

Commit

Permalink
store: Accept just containers.bootc for as bootable
Browse files Browse the repository at this point in the history
This allows us to accept images to that don't have any metadata
keys starting with `ostree`.
  • Loading branch information
cgwalters committed Oct 24, 2024
1 parent 37710b7 commit 2d0c3f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/src/container/encapsulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub const LEGACY_VERSION_LABEL: &str = "version";
/// The label which indicates where the ostree layers stop, and the
/// derived ones start.
pub const DIFFID_LABEL: &str = "ostree.final-diffid";
/// The label for bootc.
pub const BOOTC_LABEL: &str = "containers.bootc";

/// Annotation injected into the layer to say that this is an ostree commit.
/// However, because this gets lost when converted to D2S2 https://docs.docker.com/registry/spec/manifest-v2-2/
Expand Down Expand Up @@ -68,7 +70,7 @@ fn commit_meta_to_labels<'a>(
#[allow(clippy::explicit_auto_deref)]
if let Some(v) = meta.lookup::<bool>(*ostree::METADATA_KEY_BOOTABLE)? {
labels.insert(ostree::METADATA_KEY_BOOTABLE.to_string(), v.to_string());
labels.insert("containers.bootc".into(), "1".into());
labels.insert(BOOTC_LABEL.into(), "1".into());
}
// Handle any other string-typed values here.
for k in &[&ostree::METADATA_KEY_LINUX] {
Expand Down
4 changes: 3 additions & 1 deletion lib/src/container/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@ impl ImageImporter {
let config_labels = super::labels_of(&config);
if self.require_bootable {
let bootable_key = *ostree::METADATA_KEY_BOOTABLE;
let bootable = config_labels.map_or(false, |l| l.contains_key(bootable_key));
let bootable = config_labels.map_or(false, |l| {
l.contains_key(bootable_key) || l.contains_key(BOOTC_LABEL)
});
if !bootable {
anyhow::bail!("Target image does not have {bootable_key} label");
}
Expand Down

0 comments on commit 2d0c3f6

Please sign in to comment.