Fix ordering of tags in the OCI model

Before this change, we were neglecting to sort the tags by ID, which meant that pagination was broken
This commit is contained in:
Joseph Schorr 2019-03-07 12:53:02 -05:00
parent d3dd2f7b7c
commit 96072a44c0
6 changed files with 51 additions and 6 deletions

View file

@ -201,13 +201,18 @@ class OCIModel(SharedModel, RegistryDataInterface):
def list_repository_tags(self, repository_ref, include_legacy_images=False,
start_pagination_id=None,
limit=None):
limit=None,
sort_tags=False):
"""
Returns a list of all the active tags in the repository. Note that this can be a *heavy*
operation on repositories with a lot of tags, and should be avoided for more targetted
operations wherever possible.
"""
tags = list(oci.tag.list_alive_tags(repository_ref._db_id, start_pagination_id, limit))
if start_pagination_id:
assert sort_tags
tags = list(oci.tag.list_alive_tags(repository_ref._db_id, start_pagination_id, limit,
sort_tags=sort_tags))
legacy_images_map = {}
if include_legacy_images:
legacy_images_map = oci.tag.get_legacy_images_for_tags(tags)