refactor(endpoints/api/tag): refactor code for v22

this decouples the database models from the api

[TESTING->locally with docker compose]

Issue: https://coreosdev.atlassian.net/browse/QUAY-632

- [ ] It works!
- [ ] Comments provide sufficient explanations for the next contributor
- [ ] Tests cover changes and corner cases
- [ ] Follows Quay syntax patterns and format
This commit is contained in:
Charlton Austin 2017-07-06 14:50:30 -04:00
parent a3afd37c41
commit fc4b3642d3
7 changed files with 483 additions and 67 deletions

View file

@ -9,6 +9,33 @@ from endpoints.exception import NotFound
from data import model
def image_view_pre_oci(image, image_map, include_ancestors=True):
command = image.command
def docker_id(aid):
if aid not in image_map:
return ''
return image_map[aid].docker_image_id
image_data = {
'id': image.docker_image_id,
'created': format_date(image.created),
'comment': image.comment,
'command': json.loads(command) if command else None,
'size': image.storage_image_size,
'uploading': image.storage_uploading,
'sort_index': image.ancestor_length,
}
if include_ancestors:
# Calculate the ancestors string, with the DBID's replaced with the docker IDs.
ancestors = [docker_id(a) for a in image.ancestor_id_list]
image_data['ancestors'] = '/{0}/'.format('/'.join(ancestors))
return image_data
def image_view(image, image_map, include_ancestors=True):
command = image.command