Fix the dockerfile build login to work on http and https registries.

This commit is contained in:
yackob03 2014-01-24 16:25:25 -05:00
parent 72559fb948
commit aa58b840a5

View file

@ -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)