Skip to content

Commit 56d3e5d

Browse files
committed
ref(dockerclient): use docker.auth.split_repo_name instead of our own strip_prefix
1 parent d077bfe commit 56d3e5d

2 files changed

Lines changed: 2 additions & 14 deletions

File tree

rootfs/registry/dockerclient.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import docker
1212
import docker.constants
13+
from docker.auth import auth
1314
from docker.errors import APIError
1415

1516
logger = logging.getLogger(__name__)
@@ -37,7 +38,7 @@ def publish_release(self, source, target, deis_registry):
3738
name, tag = docker.utils.parse_repository_tag(target)
3839
# strip any "http://host.domain:port" prefix from the target repository name,
3940
# since we always publish to the Deis registry
40-
name = strip_prefix(name)
41+
repo, name = auth.split_repo_name(name)
4142

4243
# pull the source image from the registry
4344
# NOTE: this relies on an implementation detail of deis-builder, that
@@ -115,11 +116,5 @@ def stream_error(chunk, operation, repo, tag):
115116
raise RegistryException(message)
116117

117118

118-
def strip_prefix(name):
119-
"""Strip the schema and host:port from a Docker repository name."""
120-
paths = name.split('/')
121-
return '/'.join(p for p in paths if p and '.' not in p and ':' not in p)
122-
123-
124119
def publish_release(source, target, deis_registry):
125120
return DockerClient().publish_release(source, target, deis_registry)

rootfs/registry/tests.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from django.conf import settings
1414
from rest_framework.exceptions import PermissionDenied
1515
from registry.dockerclient import DockerClient
16-
from registry.dockerclient import strip_prefix
1716

1817

1918
@mock.patch('docker.Client')
@@ -73,9 +72,3 @@ def test_tag(self, mock_client):
7372
self.client.tag('deis/controller:v1.11.1', 'deis/controller', 'v1.11.1')
7473
with self.assertRaises(PermissionDenied):
7574
self.client.tag('localhost:5000/deis/controller:v1.11.1', 'deis/controller', 'v1.11.1')
76-
77-
def test_strip_prefix(self, mock_client):
78-
self.assertEqual(strip_prefix('quay.io/boris/riotsugar'), 'boris/riotsugar')
79-
self.assertEqual(strip_prefix('127.0.0.1:5000/boris/galaxians'), 'boris/galaxians')
80-
self.assertEqual(strip_prefix('boris/jacksonhead'), 'boris/jacksonhead')
81-
self.assertEqual(strip_prefix(':8888/boris/pink'), 'boris/pink')

0 commit comments

Comments
 (0)