Handle case where volumes in Docker->ACI are null

Fixes #1089
This commit is contained in:
Joseph Schorr 2015-12-21 12:18:38 -05:00
parent 5ac7369bf5
commit e3807c39b3

View file

@ -79,12 +79,28 @@ class ACIImage(TarImageFormatter):
return isolators
@staticmethod
def _get_docker_config_value(docker_config, key, default_value):
# Try the key itself.
result = docker_config.get(key)
if result is not None:
return result or default_value
# The the lowercase version of the key.
result = docker_config.get(key.lower())
if result is not None:
return result or default_value
return default_value
@staticmethod
def _build_ports(docker_config):
""" Builds the ports definitions for the ACI. """
ports = []
for docker_port_definition in docker_config.get('ports', docker_config.get('Ports', {})):
for docker_port_definition in ACIImage._get_docker_config_value(docker_config, 'Ports', []):
# Formats:
# port/tcp
# port/udp
@ -119,7 +135,7 @@ class ACIImage(TarImageFormatter):
def get_name(docker_volume_path):
return "volume-%s" % docker_volume_path.replace('/', '-')
for docker_volume_path in docker_config.get('volumes', docker_config.get('Volumes', {})):
for docker_volume_path in ACIImage._get_docker_config_value(docker_config, 'Volumes', []):
if not docker_volume_path:
continue