Change tag_view to avoid a DB lookup and only return the tag's image ID. We map the ID in the frontend based on the image data returned

This commit is contained in:
Joseph Schorr 2014-07-17 15:16:22 -04:00
parent 126371f8a1
commit a45054bf2e
3 changed files with 52 additions and 54 deletions

View file

@ -138,21 +138,6 @@ class RepositoryList(ApiResource):
return response
def image_view(image):
extended_props = image
if image.storage and image.storage.id:
extended_props = image.storage
command = extended_props.command
return {
'id': image.docker_image_id,
'created': format_date(extended_props.created),
'comment': extended_props.comment,
'command': json.loads(command) if command else None,
'ancestors': image.ancestors,
'dbid': image.id,
'size': extended_props.image_size
}
@resource('/v1/repository/<repopath:repository>')
class Repository(RepositoryParamResource):
@ -181,13 +166,10 @@ class Repository(RepositoryParamResource):
logger.debug('Get repo: %s/%s' % (namespace, repository))
def tag_view(tag):
image = model.get_tag_image(namespace, repository, tag.name)
if not image:
return {}
return {
'name': tag.name,
'image': image_view(image),
'image_id': tag.image.docker_image_id,
'dbid': tag.image.id
}
organization = None