Repository endpoint tags pagination (#3238)
* endpoint/api/repository: limit the number of tags returned - Limit the number of tags returned by /api/v1/repository/<ns:repo> to 500. - Uses the tag history endpoint instead, with an active tag filte. - Update UI to use tag history endpoint instead.
This commit is contained in:
parent
6d5489b254
commit
8e643ce5d9
16 changed files with 99 additions and 34 deletions
|
@ -491,7 +491,7 @@ def get_tag_image(namespace_name, repository_name, tag_name, include_storage=Fal
|
|||
return _get_repo_tag_image(tag_name, include_storage, modifier)
|
||||
|
||||
|
||||
def list_repository_tag_history(repo_obj, page=1, size=100, specific_tag=None):
|
||||
def list_repository_tag_history(repo_obj, page=1, size=100, specific_tag=None, active_tags_only=False):
|
||||
query = (RepositoryTag
|
||||
.select(RepositoryTag, Image, ImageStorage)
|
||||
.join(Image)
|
||||
|
@ -503,6 +503,9 @@ def list_repository_tag_history(repo_obj, page=1, size=100, specific_tag=None):
|
|||
.limit(size + 1)
|
||||
.offset(size * (page - 1)))
|
||||
|
||||
if active_tags_only:
|
||||
query = _tag_alive(query)
|
||||
|
||||
if specific_tag:
|
||||
query = query.where(RepositoryTag.name == specific_tag)
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class RegistryDataInterface(object):
|
|||
"""
|
||||
|
||||
@abstractmethod
|
||||
def list_repository_tag_history(self, repository_ref, page=1, size=100, specific_tag_name=None):
|
||||
def list_repository_tag_history(self, repository_ref, page=1, size=100, specific_tag_name=None, active_tags_only=False):
|
||||
"""
|
||||
Returns the history of all tags in the repository (unless filtered). This includes tags that
|
||||
have been made in-active due to newer versions of those tags coming into service.
|
||||
|
|
|
@ -164,14 +164,15 @@ class PreOCIModel(RegistryDataInterface):
|
|||
else None))
|
||||
for tag in tags]
|
||||
|
||||
def list_repository_tag_history(self, repository_ref, page=1, size=100, specific_tag_name=None):
|
||||
def list_repository_tag_history(self, repository_ref, page=1, size=100, specific_tag_name=None, active_tags_only=False):
|
||||
"""
|
||||
Returns the history of all tags in the repository (unless filtered). This includes tags that
|
||||
have been made in-active due to newer versions of those tags coming into service.
|
||||
"""
|
||||
tags, manifest_map, has_more = model.tag.list_repository_tag_history(repository_ref._db_id,
|
||||
page, size,
|
||||
specific_tag_name)
|
||||
specific_tag_name,
|
||||
active_tags_only)
|
||||
return [Tag.for_repository_tag(tag, manifest_map.get(tag.id),
|
||||
legacy_image=LegacyImage.for_image(tag.image))
|
||||
for tag in tags], has_more
|
||||
|
|
Reference in a new issue