Fix Docker Auth and our V2 registry paths to support library (i.e. namespace-less) repositories.
This support is placed behind a feature flag.
This commit is contained in:
parent
06b0f756bd
commit
e4ffaff869
37 changed files with 270 additions and 148 deletions
|
@ -10,10 +10,11 @@ TAG_REGEX = re.compile(r'^[\w][\w\.-]{0,127}$')
|
|||
TAG_ERROR = ('Invalid tag: must match [A-Za-z0-9_.-], NOT start with "." or "-", '
|
||||
'and can contain 1-128 characters')
|
||||
|
||||
def parse_namespace_repository(repository, include_tag=False):
|
||||
|
||||
def parse_namespace_repository(repository, library_namespace, include_tag=False):
|
||||
parts = repository.rstrip('/').split('/', 1)
|
||||
if len(parts) < 2:
|
||||
namespace = 'library'
|
||||
namespace = library_namespace
|
||||
repository = parts[0]
|
||||
else:
|
||||
(namespace, repository) = parts
|
||||
|
@ -30,20 +31,6 @@ def parse_namespace_repository(repository, include_tag=False):
|
|||
return (namespace, repository, tag)
|
||||
return (namespace, repository)
|
||||
|
||||
def parse_repository_name(f):
|
||||
@wraps(f)
|
||||
def wrapper(repository, *args, **kwargs):
|
||||
(namespace, repository) = parse_namespace_repository(repository)
|
||||
return f(namespace, repository, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
def parse_repository_name_and_tag(f):
|
||||
@wraps(f)
|
||||
def wrapper(repository, *args, **kwargs):
|
||||
namespace, repository, tag = parse_namespace_repository(repository, include_tag=True)
|
||||
return f(namespace, repository, tag, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
def format_robot_username(parent_username, robot_shortname):
|
||||
return '%s+%s' % (parent_username, robot_shortname)
|
||||
|
|
Reference in a new issue