Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
fix(controller/registry): strip hostname from repo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Matthew Fisher committed Aug 5, 2014
1 parent 94435fe commit 16f33bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
25 changes: 17 additions & 8 deletions controller/registry/private.py
Expand Up @@ -6,6 +6,8 @@
import urlparse
import uuid

from docker.utils import utils

from django.conf import settings


Expand All @@ -23,14 +25,21 @@ def publish_release(source, config, target):
contains the new configuration as ENV entries.
"""
try:
# parse for the tag and the repository
if ':' in source:
if '/' not in source[source.rfind(':') + 1:]:
src_tag = source[source.rfind(':') + 1:]
src_image = source[:source.rfind(':')]
else:
src_image = source
src_tag = 'latest'
repo, tag = utils.parse_repository_tag(source)

src_image = repo
src_tag = tag if tag is not None else 'latest'

nameparts = repo.rsplit('/', 1)
if len(nameparts) == 2:
if '/' in nameparts[0]:
# strip the hostname and just use the app name
src_image = '{}/{}'.format(nameparts[0].rsplit('/', 1)[1],
nameparts[1])
elif '.' in nameparts[0]:
# we got a name like registry.local:5000/registry
src_image = nameparts[1]

target_image = target.rsplit(':', 1)[0]
target_tag = target.rsplit(':', 1)[1]
image_id = _get_tag(src_image, src_tag)
Expand Down
1 change: 1 addition & 0 deletions controller/requirements.txt
Expand Up @@ -13,6 +13,7 @@ django-guardian==1.1.1
django-json-field==0.5.5
django-yamlfield==0.5
djangorestframework==2.3.13
docker-py==0.4.0
gunicorn==18.0
psycopg2==2.5.2
python-etcd==0.3.0
Expand Down
1 change: 1 addition & 0 deletions docs/docs_requirements.txt
Expand Up @@ -16,6 +16,7 @@ git+https://github.com/bacongobbler/django-fsm@add-exception-handling
django-guardian==1.1.1
django-json-field==0.5.5
djangorestframework==2.3.13
docker-py==0.4.0
gunicorn==18.0
psycopg2==2.5.2
python-etcd==0.3.0
Expand Down

0 comments on commit 16f33bf

Please sign in to comment.