From 89292d9a2fabb89b72ba28b2997185eeee8a5ac9 Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Fri, 22 Apr 2022 01:42:03 +0800 Subject: [PATCH] bundle: add support for missing annotations There are three more annotations defined by the OCI image spec, so add support for them. Signed-off-by: Jiang Liu --- src/bundle.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/bundle.rs b/src/bundle.rs index bcecb1ef6..302df66e1 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -14,7 +14,10 @@ pub const BUNDLE_ROOTFS: &str = "rootfs"; pub const BUNDLE_HOSTNAME: &str = "image-rs"; const ANNOTATION_OS: &str = "org.opencontainers.image.os"; +const ANNOTATION_OS_VERSION: &str = "org.opencontainers.image.os.version"; +const ANNOTATION_OS_FEATURES: &str = "org.opencontainers.image.os.features"; const ANNOTATION_ARCH: &str = "org.opencontainers.image.architecture"; +const ANNOTATION_VARIANT: &str = "org.opencontainers.image.variant"; const ANNOTATION_AUTHOR: &str = "org.opencontainers.image.author"; const ANNOTATION_CREATED: &str = "org.opencontainers.image.created"; const ANNOTATION_STOP_SIGNAL: &str = "org.opencontainers.image.stopSignal"; @@ -165,12 +168,29 @@ pub fn create_runtime_config( if !labels.contains_key(ANNOTATION_OS) { annotations.insert(ANNOTATION_OS.to_string(), image_config.os().to_string()); } + if !labels.contains_key(ANNOTATION_OS_VERSION) { + if let Some(version) = image_config.os_version() { + annotations.insert(ANNOTATION_OS_VERSION.to_string(), version.to_string()); + } + } + if !labels.contains_key(ANNOTATION_OS_FEATURES) { + if let Some(features) = image_config.os_features() { + if let Ok(v) = serde_json::to_string(features) { + annotations.insert(ANNOTATION_OS_FEATURES.to_string(), v); + } + } + } if !labels.contains_key(ANNOTATION_ARCH) { annotations.insert( ANNOTATION_ARCH.to_string(), image_config.architecture().to_string(), ); } + if !labels.contains_key(ANNOTATION_VARIANT) { + if let Some(variant) = image_config.variant() { + annotations.insert(ANNOTATION_VARIANT.to_string(), variant.to_string()); + } + } if !labels.contains_key(ANNOTATION_AUTHOR) { if let Some(author) = image_config.author() { annotations.insert(ANNOTATION_AUTHOR.to_string(), author.to_string());