aci: santize AC Names properly
This commit is contained in:
parent
d6abf17b4d
commit
a531ce199d
1 changed files with 16 additions and 3 deletions
|
@ -1,9 +1,15 @@
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
from app import app
|
from app import app
|
||||||
from util.registry.streamlayerformat import StreamLayerMerger
|
from util.registry.streamlayerformat import StreamLayerMerger
|
||||||
from formats.tarimageformatter import TarImageFormatter
|
from formats.tarimageformatter import TarImageFormatter
|
||||||
|
|
||||||
import json
|
|
||||||
import re
|
ACNAME_REGEX = re.compile(r'[^a-z-]+')
|
||||||
|
|
||||||
|
|
||||||
class ACIImage(TarImageFormatter):
|
class ACIImage(TarImageFormatter):
|
||||||
""" Image formatter which produces an ACI-compatible TAR.
|
""" Image formatter which produces an ACI-compatible TAR.
|
||||||
|
@ -126,6 +132,13 @@ class ACIImage(TarImageFormatter):
|
||||||
|
|
||||||
return ports
|
return ports
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _ac_name(value):
|
||||||
|
sanitized = ACNAME_REGEX.sub('-', value.lower()).strip('-')
|
||||||
|
if sanitized == '':
|
||||||
|
return str(uuid4())
|
||||||
|
return sanitized
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _build_volumes(docker_config):
|
def _build_volumes(docker_config):
|
||||||
""" Builds the volumes definitions for the ACI. """
|
""" Builds the volumes definitions for the ACI. """
|
||||||
|
@ -133,7 +146,7 @@ class ACIImage(TarImageFormatter):
|
||||||
names = set()
|
names = set()
|
||||||
|
|
||||||
def get_name(docker_volume_path):
|
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', []):
|
for docker_volume_path in ACIImage._get_docker_config_value(docker_config, 'Volumes', []):
|
||||||
if not docker_volume_path:
|
if not docker_volume_path:
|
||||||
|
|
Reference in a new issue