Show manifest digests in place of V1 ids in the tag view when possible

This commit is contained in:
Joseph Schorr 2017-03-01 18:22:40 -05:00
parent 814bbb4a96
commit af743b156b
8 changed files with 88 additions and 11 deletions

View file

@ -259,7 +259,7 @@ class Repository(RepositoryParamResource):
"""Fetch the specified repository."""
logger.debug('Get repo: %s/%s' % (namespace, repository))
def tag_view(tag):
def tag_view(tag, manifest):
tag_info = {
'name': tag.name,
'image_id': tag.image.docker_image_id,
@ -270,13 +270,18 @@ class Repository(RepositoryParamResource):
last_modified = format_date(datetime.fromtimestamp(tag.lifetime_start_ts))
tag_info['last_modified'] = last_modified
if manifest is not None:
tag_info['manifest_digest'] = manifest.digest
return tag_info
repo = model.repository.get_repository(namespace, repository)
stats = None
if repo:
tags = model.tag.list_repository_tags(namespace, repository, include_storage=True)
tag_dict = {tag.name: tag_view(tag) for tag in tags}
manifests = model.tag.get_tag_manifests(tags)
tag_dict = {tag.name: tag_view(tag, manifests.get(tag.id)) for tag in tags}
can_write = ModifyRepositoryPermission(namespace, repository).can()
can_admin = AdministerRepositoryPermission(namespace, repository).can()