diff --git a/data/model/oci/tag.py b/data/model/oci/tag.py index b90efc1f4..0a7706c96 100644 --- a/data/model/oci/tag.py +++ b/data/model/oci/tag.py @@ -78,10 +78,11 @@ def list_repository_tag_history(repository_id, page, page_size, specific_tag_nam active_tags_only=False): """ Returns a tuple of the full set of tags found in the specified repository, including those that are no longer alive (unless active_tags_only is True), and whether additional tags exist. - If specific_tag_name is given, the tags are further filtered by name. + If specific_tag_name is given, the tags are further filtered by name. Note that the + returned Manifest will not contain the manifest contents. """ query = (Tag - .select(Tag, Manifest) + .select(Tag, Manifest.id, Manifest.digest, Manifest.media_type) .join(Manifest) .where(Tag.repository == repository_id) .order_by(Tag.lifetime_start_ms.desc(), Tag.name) diff --git a/data/registry_model/datatypes.py b/data/registry_model/datatypes.py index f3bbb543b..b0352cce2 100644 --- a/data/registry_model/datatypes.py +++ b/data/registry_model/datatypes.py @@ -217,9 +217,12 @@ class Manifest(datatype('Manifest', ['digest', 'media_type', 'internal_manifest_ if manifest is None: return None + # NOTE: `manifest_bytes` will be None if not selected by certain join queries. + manifest_bytes = (Bytes.for_string_or_unicode(manifest.manifest_bytes) + if manifest.manifest_bytes is not None else None) return Manifest(db_id=manifest.id, digest=manifest.digest, - internal_manifest_bytes=Bytes.for_string_or_unicode(manifest.manifest_bytes), + internal_manifest_bytes=manifest_bytes, media_type=ManifestTable.media_type.get_name(manifest.media_type_id), inputs=dict(legacy_image=legacy_image, tag_manifest=False)) @@ -245,6 +248,7 @@ class Manifest(datatype('Manifest', ['digest', 'media_type', 'internal_manifest_ def get_parsed_manifest(self, validate=True): """ Returns the parsed manifest for this manifest. """ + assert self.internal_manifest_bytes return parse_manifest_from_bytes(self.internal_manifest_bytes, self.media_type, validate=validate) diff --git a/endpoints/api/tag.py b/endpoints/api/tag.py index 280853fdf..b6ce4e0ad 100644 --- a/endpoints/api/tag.py +++ b/endpoints/api/tag.py @@ -41,9 +41,6 @@ def _tag_dict(tag): if tag.manifest: tag_info['is_manifest_list'] = tag.manifest.is_manifest_list - if 'size' not in tag_info: - tag_info['size'] = tag.manifest.layers_compressed_size - if tag.lifetime_start_ts > 0: last_modified = format_date(datetime.utcfromtimestamp(tag.lifetime_start_ts)) tag_info['last_modified'] = last_modified