Skip to content

Commit 1002360

Browse files
Merge pull request #37 from containers/list-entry-mediatypes
fix(validation): do not enforce entry mediatypes
2 parents 6b8b068 + f0e0c2b commit 1002360

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

image/oci.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ def validate_static(entry: Dict[str, Any]) -> Tuple[bool, str]:
155155
)
156156
if not platform_valid:
157157
return platform_valid, err
158-
159-
# If the mediaType is unsupported, then error
160-
if entry["mediaType"] in UNSUPPORTED_OCI_MANIFEST_MEDIA_TYPES:
161-
return False, f"Unsupported mediaType: {entry['mediaType']}"
162158

163159
# Valid if all of the above are valid
164160
return True, ""

image/v2s2.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@
1818
MANIFEST_LIST_V2_SCHEMA, \
1919
MANIFEST_LIST_V2_ENTRY_SCHEMA
2020

21-
# A list of mediaTypes which are not supported by the v2s2 manifest spec
21+
# See doc comments below
2222
UNSUPPORTED_V2S2_MANIFEST_MEDIA_TYPES = [
2323
OCI_MANIFEST_MEDIA_TYPE
2424
]
25+
"""
26+
A list of mediaTypes which are not supported by the v2s2 manifest spec.
27+
This mainly just includes the OCI manifest mediaType.
28+
"""
29+
30+
# See doc comments below
2531
UNSUPPORTED_V2S2_MANIFEST_LIST_MEDIA_TYPES = [
2632
OCI_INDEX_MEDIA_TYPE
2733
]
34+
"""
35+
A list of mediaTypes which are not supported by the v2s2 manifest list
36+
spec. This mainly just includes the OCI index mediaType.
37+
"""
2838

2939
"""
3040
ContainerImageManifestV2S2 class
@@ -145,10 +155,6 @@ def validate_static(entry: Dict[str, Any]) -> Tuple[bool, str]:
145155
)
146156
if not platform_valid:
147157
return platform_valid, err
148-
149-
# If the mediaType is unsupported, then error
150-
if entry["mediaType"] in UNSUPPORTED_V2S2_MANIFEST_MEDIA_TYPES:
151-
return False, f"Unsupported mediaType: {entry['mediaType']}"
152158

153159
# Valid if all of the above are valid
154160
return True, ""

tests/oci_test.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,6 @@
9696
}
9797
}
9898

99-
# An example manifest list entry from the CNCF manifest v2s2 spec
100-
CNCF_MANIFEST_LIST_ENTRY_EXAMPLE = {
101-
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
102-
"digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270",
103-
"size": 7682,
104-
"platform": {
105-
"architecture": "amd64",
106-
"os": "linux",
107-
"features": [
108-
"sse4"
109-
]
110-
}
111-
}
112-
11399
# An example image index entry following the OCI spec
114100
DOCKER_BUILDX_ATTESTATION_INDEX_ENTRY = {
115101
"mediaType": "application/vnd.oci.image.manifest.v1+json",
@@ -229,14 +215,6 @@ def test_container_image_oci_image_index_entry_static_validation():
229215
assert isinstance(err, str)
230216
assert len(err) > 0
231217

232-
# CNCF (non-OCI) example should be invalid
233-
cncf_example_valid, err = ContainerImageIndexEntryOCI.validate_static(
234-
copy.deepcopy(CNCF_MANIFEST_LIST_ENTRY_EXAMPLE)
235-
)
236-
assert cncf_example_valid == False
237-
assert isinstance(err, str)
238-
assert len(err) > 0
239-
240218
def test_container_image_oci_image_index_entry_instantiation():
241219
# Invalid entry should raise ValidationError
242220
exc = None

0 commit comments

Comments
 (0)