diff --git a/formats/aci.py b/formats/aci.py index a34f91631..97be94a59 100644 --- a/formats/aci.py +++ b/formats/aci.py @@ -1,9 +1,15 @@ +import json +import re + +from uuid import uuid4 + from app import app from util.registry.streamlayerformat import StreamLayerMerger from formats.tarimageformatter import TarImageFormatter -import json -import re + +ACNAME_REGEX = re.compile(r'[^a-z-]+') + class ACIImage(TarImageFormatter): """ Image formatter which produces an ACI-compatible TAR. @@ -126,6 +132,13 @@ class ACIImage(TarImageFormatter): return ports + @staticmethod + def _ac_name(value): + sanitized = ACNAME_REGEX.sub('-', value.lower()).strip('-') + if sanitized == '': + return str(uuid4()) + return sanitized + @staticmethod def _build_volumes(docker_config): """ Builds the volumes definitions for the ACI. """ @@ -133,7 +146,7 @@ class ACIImage(TarImageFormatter): names = set() def get_name(docker_volume_path): - return "volume-%s" % docker_volume_path.replace('/', '-') + return "volume-%s" % ACIImage._ac_name(docker_volume_path) for docker_volume_path in ACIImage._get_docker_config_value(docker_config, 'Volumes', []): if not docker_volume_path: