From 0d1ac7a4bb4afdf5c25c210685b40f103e3efe5c Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 29 Jan 2019 13:11:48 -0500 Subject: [PATCH] Small optimization in manifest loading in the OCI data model --- data/registry_model/interface.py | 2 +- data/registry_model/registry_oci_model.py | 7 +++++-- data/registry_model/registry_pre_oci_model.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/data/registry_model/interface.py b/data/registry_model/interface.py index eb9edd2c7..9d990c92b 100644 --- a/data/registry_model/interface.py +++ b/data/registry_model/interface.py @@ -42,7 +42,7 @@ class RegistryDataInterface(object): or None if none. """ @abstractmethod - def get_manifest_for_tag(self, tag, backfill_if_necessary=False): + def get_manifest_for_tag(self, tag, backfill_if_necessary=False, include_legacy_image=False): """ Returns the manifest associated with the given tag. """ @abstractmethod diff --git a/data/registry_model/registry_oci_model.py b/data/registry_model/registry_oci_model.py index c1f2cffd5..2fd73cad1 100644 --- a/data/registry_model/registry_oci_model.py +++ b/data/registry_model/registry_oci_model.py @@ -114,9 +114,12 @@ class OCIModel(SharedModel, RegistryDataInterface): assert found_tag is None or not found_tag.hidden return Tag.for_tag(found_tag) - def get_manifest_for_tag(self, tag, backfill_if_necessary=False): + def get_manifest_for_tag(self, tag, backfill_if_necessary=False, include_legacy_image=False): """ Returns the manifest associated with the given tag. """ - legacy_image = oci.shared.get_legacy_image_for_manifest(tag._manifest) + legacy_image = None + if include_legacy_image: + legacy_image = oci.shared.get_legacy_image_for_manifest(tag._manifest) + return Manifest.for_manifest(tag._manifest, LegacyImage.for_image(legacy_image)) def lookup_manifest_by_digest(self, repository_ref, manifest_digest, allow_dead=False, diff --git a/data/registry_model/registry_pre_oci_model.py b/data/registry_model/registry_pre_oci_model.py index 637aa5f98..1a5094ae6 100644 --- a/data/registry_model/registry_pre_oci_model.py +++ b/data/registry_model/registry_pre_oci_model.py @@ -66,7 +66,7 @@ class PreOCIModel(SharedModel, RegistryDataInterface): assert found_tag is None or not found_tag.hidden return Tag.for_repository_tag(found_tag) - def get_manifest_for_tag(self, tag, backfill_if_necessary=False): + def get_manifest_for_tag(self, tag, backfill_if_necessary=False, include_legacy_image=False): """ Returns the manifest associated with the given tag. """ try: tag_manifest = database.TagManifest.get(tag_id=tag._db_id)