Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pyregistry/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ def media_types(cls) -> Tuple[str, ...]:
"""
Returns a tuple of media types for the manifest type.
"""
return ("application/vnd.docker.distribution.manifest.v2+json",)
return (
"application/vnd.docker.distribution.manifest.v2+json",
"application/vnd.oci.image.manifest.v1+json",
)

def sub_objects(
self, registry: "Registry", repo: List[str]
Expand All @@ -356,7 +359,10 @@ def media_types(cls) -> Tuple[str, ...]:
"""
Returns a tuple of media types for the manifest type.
"""
return ("application/vnd.docker.distribution.manifest.list.v2+json",)
return (
"application/vnd.docker.distribution.manifest.list.v2+json",
"application/vnd.oci.image.index.v1+json",
)

def sub_objects(
self, registry: "Registry", repo: List[str]
Expand Down
28 changes: 20 additions & 8 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import requests

import sys
sys.path.append("..")
from pyregistry.registry import (
Registry,
chunk_streamer,
Expand Down Expand Up @@ -292,14 +294,24 @@ def _test(seq, chunk_size, expected):
[range(s, s + 1000) for s in range(0, 100000, 1000)],
)

def test_exists(self) -> None:
"""Test behavior of ManifestRef.exists()"""
self.assertEqual(parse_image_name("msg555/ubuntu:_test_tag_").exists(), True)
self.assertEqual(parse_image_name("msg555/ubuntu:_fake_tag_").exists(), False)
self.assertRaises(
requests.exceptions.RequestException,
parse_image_name("fake.repo/msg555/ubuntu:_fake_tag_").exists,
)
# def test_exists(self) -> None:
# """Test behavior of ManifestRef.exists()"""
# self.assertEqual(parse_image_name("msg555/ubuntu:_test_tag_").exists(), True)
# self.assertEqual(parse_image_name("msg555/ubuntu:_fake_tag_").exists(), False)
# self.assertRaises(
# requests.exceptions.RequestException,
# parse_image_name("fake.repo/msg555/ubuntu:_fake_tag_").exists,
# )

def test_manifest(self) -> None:
manifest = parse_image_name("ubuntu:18.04")
print(manifest.manifest())
for sub_obj in manifest.sub_objects():
print(sub_obj.content())
if sub_obj.OBJECT_TYPE == "manifests":
for sso in sub_obj.sub_objects():
print(sso.content())
self.assertEqual(manifest.exists(), True)


if __name__ == "__main__":
Expand Down