Merge pull request #1308 from jzelinskie/aci-refresh
Fix ACI Volume Names
This commit is contained in:
commit
47506d6ec0
1 changed files with 28 additions and 19 deletions
|
@ -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.
|
||||
|
@ -79,7 +85,6 @@ class ACIImage(TarImageFormatter):
|
|||
|
||||
return isolators
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _get_docker_config_value(docker_config, key, default_value):
|
||||
# Try the key itself.
|
||||
|
@ -94,7 +99,6 @@ class ACIImage(TarImageFormatter):
|
|||
|
||||
return default_value
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _build_ports(docker_config):
|
||||
""" Builds the ports definitions for the ACI. """
|
||||
|
@ -126,14 +130,20 @@ 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. """
|
||||
volumes = []
|
||||
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:
|
||||
|
@ -146,7 +156,6 @@ class ACIImage(TarImageFormatter):
|
|||
})
|
||||
return volumes
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _build_manifest(namespace, repository, tag, docker_layer_data, synthetic_image_id):
|
||||
""" Builds an ACI manifest from the docker layer data. """
|
||||
|
@ -173,18 +182,18 @@ class ACIImage(TarImageFormatter):
|
|||
"acVersion": "0.6.1",
|
||||
"name": '%s/%s/%s' % (hostname.lower(), namespace.lower(), repository.lower()),
|
||||
"labels": [
|
||||
{
|
||||
"name": "version",
|
||||
"value": tag,
|
||||
},
|
||||
{
|
||||
"name": "arch",
|
||||
"value": docker_layer_data.get('architecture', 'amd64')
|
||||
},
|
||||
{
|
||||
"name": "os",
|
||||
"value": docker_layer_data.get('os', 'linux')
|
||||
}
|
||||
{
|
||||
"name": "version",
|
||||
"value": tag,
|
||||
},
|
||||
{
|
||||
"name": "arch",
|
||||
"value": docker_layer_data.get('architecture', 'amd64')
|
||||
},
|
||||
{
|
||||
"name": "os",
|
||||
"value": docker_layer_data.get('os', 'linux')
|
||||
}
|
||||
],
|
||||
"app": {
|
||||
"exec": exec_path,
|
||||
|
|
Reference in a new issue