Show manifest digests in place of V1 ids in the tag view when possible
This commit is contained in:
parent
814bbb4a96
commit
af743b156b
8 changed files with 88 additions and 11 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -41,19 +41,22 @@ class ListRepositoryTags(RepositoryParamResource):
|
|||
if tag.lifetime_end_ts > 0:
|
||||
tag_info['end_ts'] = tag.lifetime_end_ts
|
||||
|
||||
if tag.id in manifest_map:
|
||||
tag_info['manifest_digest'] = manifest_map[tag.id].digest
|
||||
|
||||
return tag_info
|
||||
|
||||
specific_tag = parsed_args.get('specificTag') or None
|
||||
|
||||
page = max(1, parsed_args.get('page', 1))
|
||||
limit = min(100, max(1, parsed_args.get('limit', 50)))
|
||||
tags, has_additional = model.tag.list_repository_tag_history(repo, page=page, size=limit,
|
||||
specific_tag=specific_tag)
|
||||
tags, manifest_map, more = model.tag.list_repository_tag_history(repo, page=page, size=limit,
|
||||
specific_tag=specific_tag)
|
||||
|
||||
return {
|
||||
'tags': [tag_view(tag) for tag in tags],
|
||||
'page': page,
|
||||
'has_additional': has_additional,
|
||||
'has_additional': more,
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue