endpoints.v1: return 405 for non-docker repos
This commit is contained in:
parent
48ba59d615
commit
ca7a0f14d8
3 changed files with 28 additions and 28 deletions
|
@ -183,8 +183,8 @@ def create_repository(namespace_name, repo_name):
|
|||
issue='no-repo-write-permission',
|
||||
namespace=namespace_name, repository=repo_name)
|
||||
elif 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)
|
||||
|
||||
else:
|
||||
create_perm = CreateRepositoryPermission(namespace_name)
|
||||
|
@ -228,8 +228,8 @@ def update_images(namespace_name, repo_name):
|
|||
# Make sure the repo actually exists.
|
||||
abort(404, message='Unknown repository', issue='unknown-repo')
|
||||
elif 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)
|
||||
|
||||
# Generate a job for each notification that has been added to this repo
|
||||
logger.debug('Adding notifications for repository')
|
||||
|
@ -263,8 +263,8 @@ def get_repository_images(namespace_name, repo_name):
|
|||
if not repo:
|
||||
abort(404, message='Unknown repository', issue='unknown-repo')
|
||||
elif 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)
|
||||
|
||||
logger.debug('Building repository image response')
|
||||
resp = make_response(json.dumps([]), 200)
|
||||
|
|
|
@ -85,8 +85,8 @@ def head_image_layer(namespace, repository, image_id, headers):
|
|||
if permission.can() or model.repository_is_public(namespace, repository):
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo.kind != 'image':
|
||||
msg = 'This repository is for a managing resource type other than docker images.'
|
||||
abort(415, message=msg, image_id=image_id)
|
||||
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
|
||||
abort(405, message=msg, image_id=image_id)
|
||||
|
||||
logger.debug('Looking up placement locations')
|
||||
locations, _ = model.placement_locations_and_path_docker_v1(namespace, repository, image_id)
|
||||
|
@ -123,8 +123,8 @@ def get_image_layer(namespace, repository, image_id, headers):
|
|||
if permission.can() or model.repository_is_public(namespace, repository):
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo.kind != 'image':
|
||||
msg = 'This repository is for a managing resource type other than docker images.'
|
||||
abort(415, message=msg, image_id=image_id)
|
||||
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
|
||||
abort(405, message=msg, image_id=image_id)
|
||||
|
||||
logger.debug('Looking up placement locations and path')
|
||||
locations, path = model.placement_locations_and_path_docker_v1(namespace, repository, image_id)
|
||||
|
@ -163,8 +163,8 @@ def put_image_layer(namespace, repository, image_id):
|
|||
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo.kind != 'image':
|
||||
msg = 'This repository is for a managing resource type other than docker images.'
|
||||
abort(415, message=msg, image_id=image_id)
|
||||
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
|
||||
abort(405, message=msg, image_id=image_id)
|
||||
|
||||
logger.debug('Retrieving image')
|
||||
if model.storage_exists(namespace, repository, image_id):
|
||||
|
@ -272,8 +272,8 @@ def put_image_checksum(namespace, repository, image_id):
|
|||
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo.kind != 'image':
|
||||
msg = 'This repository is for a managing resource type other than docker images.'
|
||||
abort(415, message=msg, image_id=image_id)
|
||||
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
|
||||
abort(405, message=msg, image_id=image_id)
|
||||
|
||||
# Docker Version < 0.10 (tarsum+sha):
|
||||
old_checksum = request.headers.get('X-Docker-Checksum')
|
||||
|
@ -346,8 +346,8 @@ def get_image_json(namespace, repository, image_id, headers):
|
|||
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo.kind != 'image':
|
||||
msg = 'This repository is for a managing resource type other than docker images.'
|
||||
abort(415, message=msg, image_id=image_id)
|
||||
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
|
||||
abort(405, message=msg, image_id=image_id)
|
||||
|
||||
logger.debug('Looking up repo image')
|
||||
v1_metadata = model.docker_v1_metadata(namespace, repository, image_id)
|
||||
|
@ -380,8 +380,8 @@ def get_image_ancestry(namespace, repository, image_id, headers):
|
|||
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo.kind != 'image':
|
||||
msg = 'This repository is for a managing resource type other than docker images.'
|
||||
abort(415, message=msg, image_id=image_id)
|
||||
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
|
||||
abort(405, message=msg, image_id=image_id)
|
||||
|
||||
ancestry_docker_ids = model.image_ancestry(namespace, repository, image_id)
|
||||
if ancestry_docker_ids is None:
|
||||
|
@ -405,8 +405,8 @@ def put_image_json(namespace, repository, image_id):
|
|||
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo.kind != 'image':
|
||||
msg = 'This repository is for a managing resource type other than docker images.'
|
||||
abort(415, message=msg, image_id=image_id)
|
||||
msg = 'This repository is for managing %s resources and not container images.' % repo.kind
|
||||
abort(405, message=msg, image_id=image_id)
|
||||
|
||||
logger.debug('Parsing image JSON')
|
||||
try:
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in a new issue