From aa58b840a53d478826d4d6a0528bf63b7507e5ba Mon Sep 17 00:00:00 2001 From: yackob03 Date: Fri, 24 Jan 2014 16:25:25 -0500 Subject: [PATCH] Fix the dockerfile build login to work on http and https registries. --- workers/dockerfilebuild.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/workers/dockerfilebuild.py b/workers/dockerfilebuild.py index b4e96f7fc..657c1df7e 100644 --- a/workers/dockerfilebuild.py +++ b/workers/dockerfilebuild.py @@ -122,11 +122,17 @@ class DockerfileBuildWorker(Worker): if not host: raise Exception('Invalid tag name: %s' % tag_name) - registry_endpoint = 'http://%s/v1/' % host.group(1) - docker_cl = Client(timeout=1200) - logger.debug('Attempting login to registry: %s' % registry_endpoint) - docker_cl.login('$token', token, registry=registry_endpoint) + + for protocol in ['https', 'http']: + registry_endpoint = '%s://%s/v1/' % (protocol, host.group(1)) + logger.debug('Attempting login to registry: %s' % registry_endpoint) + + try: + docker_cl.login('$token', token, registry=registry_endpoint) + break + except APIError: + pass # Probably the wrong protocol history = json.loads(docker_cl.history(built_image)) num_images = len(history)