summaryrefslogtreecommitdiff
path: root/docker/utils/utils.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-11-23 18:28:55 -0800
committerJoffrey F <joffrey@docker.com>2015-11-23 18:43:02 -0800
commit6d0e2d69d52733bbc02bf63cccce11fd9961c32d (patch)
tree82712a56f9667e6c823ce54aee1b6f74b8bf6982 /docker/utils/utils.py
parent1ca2bc58f0cf2e2cdda2734395bd3e7ad9b178bf (diff)
downloaddocker-py-6d0e2d69d52733bbc02bf63cccce11fd9961c32d.tar.gz
Update auth.resolve_repository_name
More relaxed version that matches the constraints imposed by the current version of the docker daemon. Few unit tests to verify the new cases. Client.pull was trying to set the tag value when it wasn't supposed to, fixed now. utils.parse_repository_tag is simpler and supports @sha... notation Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/utils/utils.py')
-rw-r--r--docker/utils/utils.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index 366f869..560ee8e 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -283,16 +283,14 @@ def convert_volume_binds(binds):
return result
-def parse_repository_tag(repo):
- column_index = repo.rfind(':')
- if column_index < 0:
- return repo, None
- tag = repo[column_index + 1:]
- slash_index = tag.find('/')
- if slash_index < 0:
- return repo[:column_index], tag
-
- return repo, None
+def parse_repository_tag(repo_name):
+ parts = repo_name.rsplit('@', 1)
+ if len(parts) == 2:
+ return tuple(parts)
+ parts = repo_name.rsplit(':', 1)
+ if len(parts) == 2 and '/' not in parts[1]:
+ return tuple(parts)
+ return repo_name, None
# Based on utils.go:ParseHost http://tinyurl.com/nkahcfh