Add a repository view with all images that has the list of tags for each image.

This commit is contained in:
yackob03 2013-10-10 00:40:25 -04:00
parent cffb906d64
commit 392307a937

View file

@ -4,6 +4,7 @@ import stripe
from flask import request, make_response, jsonify, abort
from flask.ext.login import login_required, current_user
from functools import wraps
from collections import defaultdict
from data import model
from app import app
@ -261,6 +262,31 @@ def role_view(repo_perm_obj):
}
@app.route('/api/repository/<path:repository>/image/', methods=['GET'])
@parse_repository_name
def list_repository_images(namespace, repository):
permission = ReadRepositoryPermission(namespace, repository)
if permission.can() or model.repository_is_public(namespace, repository):
all_images = model.get_repository_images(namespace, repository)
all_tags = model.list_repository_tags(namespace, repository)
tags_by_image_id = defaultdict(list)
for tag in all_tags:
tags_by_image_id[tag.image.docker_image_id].append(tag.name)
def add_tags(image_json):
image_json['tags'] = tags_by_image_id[image_json['id']]
return image_json
return jsonify({
'images': [add_tags(image_view(image)) for image in all_images]
})
abort(403)
@app.route('/api/repository/<path:repository>/tag/<tag>/images',
methods=['GET'])
@parse_repository_name