Skip to content

Commit

Permalink
Add artifact as a new manifest type
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
git-hyagi committed Oct 30, 2024
1 parent 23bf3a3 commit bc56195
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
17 changes: 17 additions & 0 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 vars(MEDIA_TYPE).values()
)

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
unique_together = ("digest",)
Expand Down
9 changes: 5 additions & 4 deletions pulp_container/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down

0 comments on commit bc56195

Please sign in to comment.