Merge pull request #1090 from coreos-inc/acinovolfix

Handle case where volumes in Docker->ACI are null
This commit is contained in:
josephschorr 2015-12-22 15:59:28 -05:00
commit 0237509eec

View file

@ -79,12 +79,28 @@ class ACIImage(TarImageFormatter):
return isolators 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 @staticmethod
def _build_ports(docker_config): def _build_ports(docker_config):
""" Builds the ports definitions for the ACI. """ """ Builds the ports definitions for the ACI. """
ports = [] 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: # Formats:
# port/tcp # port/tcp
# port/udp # port/udp
@ -119,7 +135,7 @@ class ACIImage(TarImageFormatter):
def get_name(docker_volume_path): def get_name(docker_volume_path):
return "volume-%s" % docker_volume_path.replace('/', '-') 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: if not docker_volume_path:
continue continue