From 58b6af8c9f743ff90099f2cf038c998e09231153 Mon Sep 17 00:00:00 2001 From: Paul Hildebrandt Date: Wed, 13 Nov 2024 14:23:23 +0100 Subject: [PATCH 1/4] Add mediatypes for oci.log Signed-off-by: Paul Hildebrandt --- src/python_gardenlinux_lib/features/parse_features.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python_gardenlinux_lib/features/parse_features.py b/src/python_gardenlinux_lib/features/parse_features.py index be1ab278..c81f42c3 100644 --- a/src/python_gardenlinux_lib/features/parse_features.py +++ b/src/python_gardenlinux_lib/features/parse_features.py @@ -35,6 +35,7 @@ "vhd.log", "ova.log", "raw.log", + "oci.log", "initrd", "tar.gz", "qcow2", @@ -85,6 +86,7 @@ "platform.test.xml": "application/io.gardenlinux.io.platform.test.xml", "chroot.test.log": "application/io.gardenlinux.io.chroot.test.log", "chroot.test.xml": "application/io.gardenlinux.io.chroot.test.xml", + "oci.log": "application/io.gardenlinux.log" } From e4c2f192e7d68e1276a0ed64262bb2195b8aa6bf Mon Sep 17 00:00:00 2001 From: Paul Hildebrandt Date: Wed, 13 Nov 2024 16:41:48 +0100 Subject: [PATCH 2/4] Make annotations optional Signed-off-by: Paul Hildebrandt --- .../features/parse_features.py | 2 +- src/python_gardenlinux_lib/oras/registry.py | 34 +++++++------------ src/python_gardenlinux_lib/oras/schemas.py | 1 - 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/python_gardenlinux_lib/features/parse_features.py b/src/python_gardenlinux_lib/features/parse_features.py index c81f42c3..5c6239cc 100644 --- a/src/python_gardenlinux_lib/features/parse_features.py +++ b/src/python_gardenlinux_lib/features/parse_features.py @@ -86,7 +86,7 @@ "platform.test.xml": "application/io.gardenlinux.io.platform.test.xml", "chroot.test.log": "application/io.gardenlinux.io.chroot.test.log", "chroot.test.xml": "application/io.gardenlinux.io.chroot.test.xml", - "oci.log": "application/io.gardenlinux.log" + "oci.log": "application/io.gardenlinux.log", } diff --git a/src/python_gardenlinux_lib/oras/registry.py b/src/python_gardenlinux_lib/oras/registry.py index c624af56..3ef14611 100644 --- a/src/python_gardenlinux_lib/oras/registry.py +++ b/src/python_gardenlinux_lib/oras/registry.py @@ -228,27 +228,19 @@ def get_manifest_meta_data_by_cname( return None for manifest_meta in index["manifests"]: - if "annotations" not in manifest_meta: - logger.debug("Manifest annotations was none, which is invalid") - return None - - if "cname" not in manifest_meta["annotations"]: - logger.debug("cname annotation was none, which is invalid") - return None - - if "architecture" not in manifest_meta["annotations"]: - logger.debug("architecture annotation was none, which is invalid") - return None - - if "platform" not in manifest_meta: - logger.debug("platform data was none, which is invalid") - return None - if ( - manifest_meta["annotations"]["cname"] == cname - and manifest_meta["annotations"]["architecture"] == arch - and manifest_meta["platform"]["os.version"] == version - ): - return manifest_meta + # Annotations are optional: + # https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md#properties + + if "annotations" in manifest_meta: + if ( + "cname" in manifest_meta["annotations"] + and "architecture" in manifest_meta["annotations"] + and "platform" in manifest_meta["annotations"] + and manifest_meta["annotations"]["cname"] == cname + and manifest_meta["annotations"]["architecture"] == arch + and manifest_meta["platform"]["os.version"] == version + ): + return manifest_meta return None diff --git a/src/python_gardenlinux_lib/oras/schemas.py b/src/python_gardenlinux_lib/oras/schemas.py index 6f2d2d6a..51626e17 100644 --- a/src/python_gardenlinux_lib/oras/schemas.py +++ b/src/python_gardenlinux_lib/oras/schemas.py @@ -56,5 +56,4 @@ "schemaVersion": 2, "mediaType": "application/vnd.oci.image.index.v1+json", "manifests": [], - "annotations": {}, } From 40f70b7984e1260fd0f5cd70504eaf05737cba22 Mon Sep 17 00:00:00 2001 From: Paul Hildebrandt Date: Wed, 13 Nov 2024 17:25:38 +0100 Subject: [PATCH 3/4] Make annotations optional Signed-off-by: Paul Hildebrandt --- src/python_gardenlinux_lib/oras/registry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_gardenlinux_lib/oras/registry.py b/src/python_gardenlinux_lib/oras/registry.py index 3ef14611..b83a0c14 100644 --- a/src/python_gardenlinux_lib/oras/registry.py +++ b/src/python_gardenlinux_lib/oras/registry.py @@ -235,7 +235,7 @@ def get_manifest_meta_data_by_cname( if ( "cname" in manifest_meta["annotations"] and "architecture" in manifest_meta["annotations"] - and "platform" in manifest_meta["annotations"] + and "os.version" in manifest_meta["platform"] and manifest_meta["annotations"]["cname"] == cname and manifest_meta["annotations"]["architecture"] == arch and manifest_meta["platform"]["os.version"] == version From b0346b243e254e878cd100e06555a7c1be1de8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20M=C3=BCnch?= Date: Wed, 13 Nov 2024 17:34:55 +0100 Subject: [PATCH 4/4] black... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Malte Münch --- src/python_gardenlinux_lib/oras/registry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_gardenlinux_lib/oras/registry.py b/src/python_gardenlinux_lib/oras/registry.py index b83a0c14..ecf355f4 100644 --- a/src/python_gardenlinux_lib/oras/registry.py +++ b/src/python_gardenlinux_lib/oras/registry.py @@ -228,7 +228,7 @@ def get_manifest_meta_data_by_cname( return None for manifest_meta in index["manifests"]: - # Annotations are optional: + # Annotations are optional: # https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md#properties if "annotations" in manifest_meta: