Skip to content

Commit 16f33bf

Browse files
author
Matthew Fisher
committed
fix(controller/registry): strip hostname from repo
The changes to the registry module did not strip the hostname from the app image. This fixes that by properly parsing the source for the repository name in the registry and the tag.
1 parent 94435fe commit 16f33bf

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

controller/registry/private.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import urlparse
77
import uuid
88

9+
from docker.utils import utils
10+
911
from django.conf import settings
1012

1113

@@ -23,14 +25,21 @@ def publish_release(source, config, target):
2325
contains the new configuration as ENV entries.
2426
"""
2527
try:
26-
# parse for the tag and the repository
27-
if ':' in source:
28-
if '/' not in source[source.rfind(':') + 1:]:
29-
src_tag = source[source.rfind(':') + 1:]
30-
src_image = source[:source.rfind(':')]
31-
else:
32-
src_image = source
33-
src_tag = 'latest'
28+
repo, tag = utils.parse_repository_tag(source)
29+
30+
src_image = repo
31+
src_tag = tag if tag is not None else 'latest'
32+
33+
nameparts = repo.rsplit('/', 1)
34+
if len(nameparts) == 2:
35+
if '/' in nameparts[0]:
36+
# strip the hostname and just use the app name
37+
src_image = '{}/{}'.format(nameparts[0].rsplit('/', 1)[1],
38+
nameparts[1])
39+
elif '.' in nameparts[0]:
40+
# we got a name like registry.local:5000/registry
41+
src_image = nameparts[1]
42+
3443
target_image = target.rsplit(':', 1)[0]
3544
target_tag = target.rsplit(':', 1)[1]
3645
image_id = _get_tag(src_image, src_tag)

controller/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ django-guardian==1.1.1
1313
django-json-field==0.5.5
1414
django-yamlfield==0.5
1515
djangorestframework==2.3.13
16+
docker-py==0.4.0
1617
gunicorn==18.0
1718
psycopg2==2.5.2
1819
python-etcd==0.3.0

docs/docs_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ git+https://github.com/bacongobbler/django-fsm@add-exception-handling
1616
django-guardian==1.1.1
1717
django-json-field==0.5.5
1818
djangorestframework==2.3.13
19+
docker-py==0.4.0
1920
gunicorn==18.0
2021
psycopg2==2.5.2
2122
python-etcd==0.3.0

0 commit comments

Comments
 (0)