Allow redirects to specific tags
This commit is contained in:
parent
4012e1b327
commit
6968c148f7
2 changed files with 23 additions and 7 deletions
|
@ -4,16 +4,25 @@ from functools import wraps
|
|||
from uuid import uuid4
|
||||
|
||||
|
||||
def parse_namespace_repository(repository):
|
||||
def parse_namespace_repository(repository, tag=False):
|
||||
parts = repository.rstrip('/').split('/', 1)
|
||||
if len(parts) < 2:
|
||||
namespace = 'library'
|
||||
repository = parts[0]
|
||||
else:
|
||||
(namespace, repository) = parts
|
||||
repository = urllib.quote_plus(repository)
|
||||
return (namespace, repository)
|
||||
|
||||
if tag:
|
||||
parts = repository.split(':', 1)
|
||||
if len(parts) < 2:
|
||||
tag = None
|
||||
else:
|
||||
(repository, tag) = parts
|
||||
|
||||
repository = urllib.quote_plus(repository)
|
||||
if tag:
|
||||
return (namespace, repository, tag)
|
||||
return (namespace, repository)
|
||||
|
||||
def parse_repository_name(f):
|
||||
@wraps(f)
|
||||
|
@ -22,6 +31,13 @@ def parse_repository_name(f):
|
|||
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, 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