Reverse the order of get_parent_images
This commit is contained in:
parent
8723fc4def
commit
4314882fa0
4 changed files with 8 additions and 8 deletions
|
@ -14,7 +14,9 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def get_parent_images(namespace_name, repository_name, image_obj):
|
||||
""" Returns a list of parent Image objects in chronilogical order. """
|
||||
""" Returns a list of parent Image objects starting with the most recent parent
|
||||
and ending with the base layer.
|
||||
"""
|
||||
parents = image_obj.ancestors
|
||||
|
||||
# Ancestors are in the format /<root>/<intermediate>/.../<parent>/, with each path section
|
||||
|
@ -31,7 +33,7 @@ def get_parent_images(namespace_name, repository_name, image_obj):
|
|||
|
||||
id_to_image = {unicode(image.id): image for image in parents}
|
||||
|
||||
return [id_to_image[parent_id] for parent_id in parent_db_ids]
|
||||
return [id_to_image[parent_id] for parent_id in reversed(parent_db_ids)]
|
||||
|
||||
|
||||
def get_repo_image(namespace_name, repository_name, docker_image_id):
|
||||
|
|
|
@ -147,9 +147,7 @@ class RepositoryTagImages(RepositoryParamResource):
|
|||
for image in parent_images:
|
||||
image_map[str(image.id)] = image
|
||||
|
||||
parents = list(parent_images)
|
||||
parents.reverse()
|
||||
all_images = [tag_image] + parents
|
||||
all_images = [tag_image] + list(parent_images)
|
||||
|
||||
return {
|
||||
'images': [image_view(image, image_map) for image in all_images]
|
||||
|
|
|
@ -390,7 +390,7 @@ def get_image_ancestry(namespace, repository, image_id, headers):
|
|||
parents = model.image.get_parent_images(namespace, repository, image)
|
||||
|
||||
ancestry_docker_ids = [image.docker_image_id]
|
||||
ancestry_docker_ids.extend([parent.docker_image_id for parent in reversed(parents)])
|
||||
ancestry_docker_ids.extend([parent.docker_image_id for parent in parents])
|
||||
|
||||
# We can not use jsonify here because we are returning a list not an object
|
||||
response = make_response(json.dumps(ancestry_docker_ids), 200)
|
||||
|
@ -510,7 +510,7 @@ def process_image_changes(namespace, repository, image_id):
|
|||
parent_trie_path = None
|
||||
if parents:
|
||||
parent_trie_path, parent_locations = process_image_changes(namespace, repository,
|
||||
parents[-1].docker_image_id)
|
||||
parents[0].docker_image_id)
|
||||
|
||||
# Read in the collapsed layer state of the filesystem for the parent
|
||||
parent_trie = changes.empty_fs()
|
||||
|
|
|
@ -29,7 +29,7 @@ def _open_stream(formatter, namespace, repository, tag, synthetic_image_id, imag
|
|||
# the database.
|
||||
with database.UseThenDisconnect(app.config):
|
||||
image_list = list(model.image.get_parent_images(namespace, repository, repo_image))
|
||||
image_list.append(repo_image)
|
||||
image_list.insert(0, repo_image)
|
||||
|
||||
def get_next_image():
|
||||
for current_image in image_list:
|
||||
|
|
Reference in a new issue