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

@ -82,6 +82,16 @@ def filter_tags_have_repository_event(query, event):
.where(RepositoryNotification.event == event)
.order_by(RepositoryTag.lifetime_start_ts.desc()))
def get_tag_manifests(tags):
""" Returns a map from tag ID to its associated manifest, if any. """
if not tags:
return dict()
manifests = TagManifest.select().where(TagManifest.tag << [t.id for t in tags])
return {manifest.tag_id:manifest for manifest in manifests}
def list_repository_tags(namespace_name, repository_name, include_hidden=False,
include_storage=False):
to_select = (RepositoryTag, Image)
@ -296,6 +306,7 @@ def list_repository_tag_history(repo_obj, page=1, size=100, specific_tag=None):
query = (RepositoryTag
.select(RepositoryTag, Image)
.join(Image)
.switch(RepositoryTag)
.where(RepositoryTag.repository == repo_obj)
.where(RepositoryTag.hidden == False)
.order_by(RepositoryTag.lifetime_start_ts.desc(), RepositoryTag.name)
@ -306,7 +317,11 @@ def list_repository_tag_history(repo_obj, page=1, size=100, specific_tag=None):
query = query.where(RepositoryTag.name == specific_tag)
tags = list(query)
return tags[0:size], len(tags) > size
if not tags:
return [], {}, False
manifest_map = get_tag_manifests(tags)
return tags[0:size], manifest_map, len(tags) > size
def revert_tag(repo_obj, tag_name, docker_image_id):