refactor(data+endpoints): code review changes

this puts the view logic on the object and adds a parameter for logging

[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-10 14:45:23 -04:00
parent 897a091692
commit 131acde317
6 changed files with 73 additions and 70 deletions

View file

@ -9,33 +9,6 @@ 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