From 844203bc5e28534cc52224ad3382dbd8658a4606 Mon Sep 17 00:00:00 2001 From: git-hyagi <45576767+git-hyagi@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:28:16 -0300 Subject: [PATCH] Add artifact as a new manifest type [noissue] --- pulp_container/app/models.py | 17 +++++++++++++++++ pulp_container/constants.py | 9 +++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pulp_container/app/models.py b/pulp_container/app/models.py index dea23e24d..c544b752b 100644 --- a/pulp_container/app/models.py +++ b/pulp_container/app/models.py @@ -199,6 +199,9 @@ def init_manifest_nature(self): elif media_type := self.is_cosign(): self.type = self.get_cosign_type(media_type) return True + elif self.is_artifact(): + self.type = MANIFEST_TYPE.ARTIFACT + return True elif self.is_manifest_image(): self.type = MANIFEST_TYPE.IMAGE return True @@ -244,6 +247,20 @@ def is_helm_chart(self): except KeyError: return False + def is_artifact(self): + # artifact is valid only for OCI spec + if self.media_type != MEDIA_TYPE.MANIFEST_OCI: + return False + + if self.json_manifest.get("artifactType", None): + return True + + manifest_config_media_type = self.json_manifest["config"]["mediaType"] + return ( + manifest_config_media_type == MEDIA_TYPE.OCI_EMPTY_JSON + or manifest_config_media_type not in MEDIA_TYPE + ) + class Meta: default_related_name = "%(app_label)s_%(model_name)s" unique_together = ("digest",) diff --git a/pulp_container/constants.py b/pulp_container/constants.py index 0a69ebdff..ecb48edab 100644 --- a/pulp_container/constants.py +++ b/pulp_container/constants.py @@ -77,14 +77,15 @@ SIGNATURE_API_EXTENSION_VERSION = 2 MANIFEST_TYPE = SimpleNamespace( - IMAGE="image", + ARTIFACT="artifact", BOOTABLE="bootable", - FLATPAK="flatpak", - HELM="helm", - COSIGN_SIGNATURE="cosign_signature", COSIGN_ATTESTATION="cosign_attestation", COSIGN_ATTESTATION_BUNDLE="cosign_attestation_bundle", COSIGN_SBOM="cosign_sbom", + COSIGN_SIGNATURE="cosign_signature", + FLATPAK="flatpak", + HELM="helm", + IMAGE="image", INDEX="index", UNKNOWN="unknown", )