diff --git a/data/registry_model/registry_oci_model.py b/data/registry_model/registry_oci_model.py index 097d1ca11..cf288d0e2 100644 --- a/data/registry_model/registry_oci_model.py +++ b/data/registry_model/registry_oci_model.py @@ -6,10 +6,10 @@ from contextlib import contextmanager from data import database from data import model from data.model import oci, DataModelException +from data.model.oci.retriever import RepositoryContentRetriever from data.database import db_transaction, Image from data.registry_model.interface import RegistryDataInterface -from data.registry_model.datatypes import (Tag, Manifest, LegacyImage, Label, SecurityScanStatus, - RepositoryReference) +from data.registry_model.datatypes import Tag, Manifest, LegacyImage, Label, SecurityScanStatus from data.registry_model.shared import SharedModel from data.registry_model.label_handlers import apply_label_to_manifest from image.docker import ManifestException @@ -457,15 +457,7 @@ class OCIModel(SharedModel, RegistryDataInterface): except database.Manifest.DoesNotExist: return None - repository_ref = RepositoryReference.for_id(manifest_row.repository_id) - - def _lookup_blob(digest): - blob = self.get_repo_blob_by_digest(repository_ref, digest, include_placements=True) - if blob is None: - return None - - return storage.get_content(blob.placements, blob.storage_path) - - return parsed.get_v1_compatible_manifest(namespace_name, repo_name, tag_name, _lookup_blob) + retriever = RepositoryContentRetriever(manifest_row.repository_id, storage) + return parsed.get_v1_compatible_manifest(namespace_name, repo_name, tag_name, retriever) oci_model = OCIModel() diff --git a/data/registry_model/test/test_interface.py b/data/registry_model/test/test_interface.py index b171f30b6..77330fa5d 100644 --- a/data/registry_model/test/test_interface.py +++ b/data/registry_model/test/test_interface.py @@ -763,6 +763,13 @@ def test_create_manifest_and_retarget_tag(registry_model): assert len(layers) == 1 +def test_get_schema1_parsed_manifest(registry_model): + repository_ref = registry_model.lookup_repository('devtable', 'simple') + latest_tag = registry_model.get_repo_tag(repository_ref, 'latest', include_legacy_image=True) + manifest = registry_model.get_manifest_for_tag(latest_tag) + assert registry_model.get_schema1_parsed_manifest(manifest, '', '', '', storage) + + def test_create_manifest_and_retarget_tag_with_labels(registry_model): repository_ref = registry_model.lookup_repository('devtable', 'simple') latest_tag = registry_model.get_repo_tag(repository_ref, 'latest', include_legacy_image=True)