Refactor how parsed_args are passed to methods

This commit is contained in:
Jake Moshenko 2016-01-26 16:27:36 -05:00
parent daab1b3964
commit 018bf8c5ad
13 changed files with 142 additions and 137 deletions

View file

@ -17,12 +17,12 @@ class ListRepositoryTags(RepositoryParamResource):
""" Resource for listing full repository tag history, alive *and dead*. """
@require_repo_read
@parse_args
@parse_args()
@query_param('specificTag', 'Filters the tags to the specific tag.', type=str, default='')
@query_param('limit', 'Limit to the number of results to return per page. Max 100.', type=int, default=50)
@query_param('page', 'Page index for the results. Default 1.', type=int, default=1)
@nickname('listRepoTags')
def get(self, args, namespace, repository):
def get(self, namespace, repository, parsed_args):
repo = model.repository.get_repository(namespace, repository)
if not repo:
raise NotFound()
@ -42,10 +42,10 @@ class ListRepositoryTags(RepositoryParamResource):
return tag_info
specific_tag = args.get('specificTag') or None
specific_tag = parsed_args.get('specificTag') or None
page = max(1, args.get('page', 1))
limit = min(100, max(1, args.get('limit', 50)))
page = max(1, parsed_args.get('page', 1))
limit = min(100, max(1, parsed_args.get('limit', 50)))
# Note: We ask for limit+1 here, so we can check to see if there are
# additional pages of results.
@ -135,10 +135,10 @@ class RepositoryTagImages(RepositoryParamResource):
""" Resource for listing the images in a specific repository tag. """
@require_repo_read
@nickname('listTagImages')
@parse_args
@parse_args()
@query_param('owned', 'If specified, only images wholely owned by this tag are returned.',
type=truthy_bool, default=False)
def get(self, args, namespace, repository, tag):
def get(self, namespace, repository, tag, parsed_args):
""" List the images for the specified repository tag. """
try:
tag_image = model.tag.get_tag_image(namespace, repository, tag)
@ -158,7 +158,7 @@ class RepositoryTagImages(RepositoryParamResource):
# Filter the images returned to those not found in the ancestry of any of the other tags in
# the repository.
if args['owned']:
if parsed_args['owned']:
all_tags = model.tag.list_repository_tags(namespace, repository)
for current_tag in all_tags:
if current_tag.name == tag:
@ -174,7 +174,7 @@ class RepositoryTagImages(RepositoryParamResource):
return {
'images': [image_view(image, image_map_all) for image in all_images
if not args['owned'] or (str(image.id) in image_map)]
if not parsed_args['owned'] or (str(image.id) in image_map)]
}