Change appr error if you try to push to an image repository
501 was confusing to the users, so change to 405 and add an error explaining why the push failed Fixes https://github.com/app-registry/helm-plugin/issues/8#issuecomment-291553739
This commit is contained in:
parent
1bfca871ec
commit
8c10b0787d
2 changed files with 5 additions and 5 deletions
|
@ -2,10 +2,10 @@ import logging
|
|||
|
||||
from functools import wraps
|
||||
|
||||
from flask import abort
|
||||
|
||||
from data import model
|
||||
|
||||
from util.http import abort
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -26,7 +26,7 @@ def disallow_for_image_repository(get_reponame_method=_get_reponame_kwargs):
|
|||
image_repo = model.repository.get_repository(namespace_name, repo_name, kind_filter='image')
|
||||
if image_repo is not None:
|
||||
logger.debug('Tried to invoked a CNR method on an image repository')
|
||||
abort(501)
|
||||
abort(405, message='Cannot push an application to an image repository with the same name')
|
||||
return func(*args, **kwargs)
|
||||
return wrapped
|
||||
return wrapper
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from werkzeug.exceptions import NotImplemented as NIE
|
||||
from werkzeug.exceptions import HTTPException
|
||||
|
||||
from data import model
|
||||
from endpoints.appr import require_app_repo_read
|
||||
|
@ -14,6 +14,6 @@ def test_require_app_repo_read(app):
|
|||
def empty(**kwargs):
|
||||
called[0] = True
|
||||
|
||||
with pytest.raises(NIE):
|
||||
with pytest.raises(HTTPException):
|
||||
empty(namespace='devtable', package_name='simple')
|
||||
assert not called[0]
|
||||
|
|
Reference in a new issue