Merge pull request #3350 from quay/small-manifest-opt

Small optimization in manifest loading in the OCI data model
This commit is contained in:
Joseph Schorr 2019-01-29 13:16:37 -05:00 committed by GitHub
commit 40c0352dd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -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 = 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,

View file

@ -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)