endpoints.v1: return 405 for non-docker repos

This commit is contained in:
Jimmy Zelinskie 2017-03-22 16:53:12 -04:00 committed by Joseph Schorr
parent 48ba59d615
commit ca7a0f14d8
3 changed files with 28 additions and 28 deletions

View file

@ -29,8 +29,8 @@ def get_tags(namespace_name, repo_name):
if permission.can() or model.repository_is_public(namespace_name, repo_name):
repo = model.get_repository(namespace_name, repo_name)
if repo.kind != 'image':
msg = 'This repository is for a managing resource type other than docker images.'
abort(415, message=msg, namespace=namespace_name)
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
abort(405, message=msg, namespace=namespace_name)
tags = model.list_tags(namespace_name, repo_name)
tag_map = {tag.name: tag.image.docker_image_id for tag in tags}
@ -49,8 +49,8 @@ def get_tag(namespace_name, repo_name, tag):
if permission.can() or model.repository_is_public(namespace_name, repo_name):
repo = model.get_repository(namespace_name, repo_name)
if repo.kind != 'image':
msg = 'This repository is for a managing resource type other than docker images.'
abort(415, message=msg, namespace=namespace_name)
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
abort(405, message=msg, namespace=namespace_name)
image_id = model.find_image_id_by_tag(namespace_name, repo_name, tag)
if image_id is None:
@ -76,8 +76,8 @@ def put_tag(namespace_name, repo_name, tag):
repo = model.get_repository(namespace_name, repo_name)
if repo.kind != 'image':
msg = 'This repository is for a managing resource type other than docker images.'
abort(415, message=msg, namespace=namespace_name)
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
abort(405, message=msg, namespace=namespace_name)
image_id = json.loads(request.data)
model.create_or_update_tag(namespace_name, repo_name, image_id, tag)
@ -103,8 +103,8 @@ def delete_tag(namespace_name, repo_name, tag):
if permission.can():
repo = model.get_repository(namespace_name, repo_name)
if repo.kind != 'image':
msg = 'This repository is for a managing resource type other than docker images.'
abort(415, message=msg, namespace=namespace_name)
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
abort(405, message=msg, namespace=namespace_name)
model.delete_tag(namespace_name, repo_name, tag)
track_and_log('delete_tag', model.get_repository(namespace_name, repo_name), tag=tag)