diff --git a/image/oci.py b/image/oci.py index 7e076a7..fff9fb0 100644 --- a/image/oci.py +++ b/image/oci.py @@ -155,10 +155,6 @@ def validate_static(entry: Dict[str, Any]) -> Tuple[bool, str]: ) if not platform_valid: return platform_valid, err - - # If the mediaType is unsupported, then error - if entry["mediaType"] in UNSUPPORTED_OCI_MANIFEST_MEDIA_TYPES: - return False, f"Unsupported mediaType: {entry['mediaType']}" # Valid if all of the above are valid return True, "" diff --git a/image/v2s2.py b/image/v2s2.py index fbac307..86996de 100644 --- a/image/v2s2.py +++ b/image/v2s2.py @@ -18,13 +18,23 @@ MANIFEST_LIST_V2_SCHEMA, \ MANIFEST_LIST_V2_ENTRY_SCHEMA -# A list of mediaTypes which are not supported by the v2s2 manifest spec +# See doc comments below UNSUPPORTED_V2S2_MANIFEST_MEDIA_TYPES = [ OCI_MANIFEST_MEDIA_TYPE ] +""" +A list of mediaTypes which are not supported by the v2s2 manifest spec. +This mainly just includes the OCI manifest mediaType. +""" + +# See doc comments below UNSUPPORTED_V2S2_MANIFEST_LIST_MEDIA_TYPES = [ OCI_INDEX_MEDIA_TYPE ] +""" +A list of mediaTypes which are not supported by the v2s2 manifest list +spec. This mainly just includes the OCI index mediaType. +""" """ ContainerImageManifestV2S2 class @@ -145,10 +155,6 @@ def validate_static(entry: Dict[str, Any]) -> Tuple[bool, str]: ) if not platform_valid: return platform_valid, err - - # If the mediaType is unsupported, then error - if entry["mediaType"] in UNSUPPORTED_V2S2_MANIFEST_MEDIA_TYPES: - return False, f"Unsupported mediaType: {entry['mediaType']}" # Valid if all of the above are valid return True, "" diff --git a/tests/oci_test.py b/tests/oci_test.py index b04723f..393084e 100644 --- a/tests/oci_test.py +++ b/tests/oci_test.py @@ -96,20 +96,6 @@ } } -# An example manifest list entry from the CNCF manifest v2s2 spec -CNCF_MANIFEST_LIST_ENTRY_EXAMPLE = { - "mediaType": "application/vnd.docker.distribution.manifest.v2+json", - "digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270", - "size": 7682, - "platform": { - "architecture": "amd64", - "os": "linux", - "features": [ - "sse4" - ] - } -} - # An example image index entry following the OCI spec DOCKER_BUILDX_ATTESTATION_INDEX_ENTRY = { "mediaType": "application/vnd.oci.image.manifest.v1+json", @@ -229,14 +215,6 @@ def test_container_image_oci_image_index_entry_static_validation(): assert isinstance(err, str) assert len(err) > 0 - # CNCF (non-OCI) example should be invalid - cncf_example_valid, err = ContainerImageIndexEntryOCI.validate_static( - copy.deepcopy(CNCF_MANIFEST_LIST_ENTRY_EXAMPLE) - ) - assert cncf_example_valid == False - assert isinstance(err, str) - assert len(err) > 0 - def test_container_image_oci_image_index_entry_instantiation(): # Invalid entry should raise ValidationError exc = None