Convert V2's tag endpoints to use the new data model interface
This commit is contained in:
parent
6b5064aba4
commit
e91ba98e1b
5 changed files with 31 additions and 7 deletions
|
@ -1,9 +1,10 @@
|
|||
from flask import jsonify
|
||||
|
||||
from auth.registry_jwt_auth import process_registry_jwt_auth
|
||||
from data.registry_model import registry_model
|
||||
from endpoints.decorators import anon_protect, parse_repository_name
|
||||
from endpoints.v2 import v2_bp, require_repo_read, paginate
|
||||
from endpoints.v2.models_pre_oci import data_model as model
|
||||
from endpoints.v2.errors import NameUnknown
|
||||
|
||||
|
||||
@v2_bp.route('/<repopath:repository>/tags/list', methods=['GET'])
|
||||
|
@ -13,10 +14,18 @@ from endpoints.v2.models_pre_oci import data_model as model
|
|||
@anon_protect
|
||||
@paginate()
|
||||
def list_all_tags(namespace_name, repo_name, start_id, limit, pagination_callback):
|
||||
tags = list(model.repository_tags(namespace_name, repo_name, start_id, limit))
|
||||
repository_ref = registry_model.lookup_repository(namespace_name, repo_name)
|
||||
if repository_ref is None:
|
||||
raise NameUnknown()
|
||||
|
||||
# NOTE: We add 1 to the limit because that's how pagination_callback knows if there are
|
||||
# additional tags.
|
||||
tags = registry_model.list_repository_tags(repository_ref, start_pagination_id=start_id,
|
||||
limit=limit + 1)
|
||||
response = jsonify({
|
||||
'name': '{0}/{1}'.format(namespace_name, repo_name),
|
||||
'tags': [tag.name for tag in tags][0:limit],})
|
||||
'tags': [tag.name for tag in tags][0:limit],
|
||||
})
|
||||
|
||||
pagination_callback(tags, response)
|
||||
return response
|
||||
|
|
Reference in a new issue