Repeat after me: JSONPathDict is not a dict

This commit is contained in:
Jake Moshenko 2017-01-11 15:17:12 -05:00
parent fe9f97cd0e
commit d8ae802956

View file

@ -172,7 +172,7 @@ class DockerV1ToACIManifestTranslator(object):
def build_manifest(repo_image, tag, synthetic_image_id):
""" Builds an ACI manifest of an existing repository image. """
docker_layer_data = JSONPathDict(repo_image.compat_metadata)
config = docker_layer_data['config'] or {}
config = docker_layer_data['config'] or JSONPathDict({})
namespace = repo_image.repository.namespace_name
repo_name = repo_image.repository.name
@ -192,7 +192,7 @@ class DockerV1ToACIManifestTranslator(object):
hostname = hostname.split(':', 1)[0]
# Calculate the environment variables.
docker_env_vars = config.get('Env', []) or []
docker_env_vars = config.get('Env') or []
env_vars = []
for var in docker_env_vars:
pieces = var.split('=')
@ -212,26 +212,26 @@ class DockerV1ToACIManifestTranslator(object):
},
{
"name": "arch",
"value": docker_layer_data.get('architecture', 'amd64')
"value": docker_layer_data.get('architecture') or 'amd64'
},
{
"name": "os",
"value": docker_layer_data.get('os', 'linux')
"value": docker_layer_data.get('os') or 'linux'
}
],
"app": {
"exec": exec_path,
# Below, `or 'root'` is required to replace empty string from Dockerfiles.
"user": config.get('User', '') or 'root',
"group": config.get('Group', '') or 'root',
"user": config.get('User') or 'root',
"group": config.get('Group') or 'root',
"eventHandlers": [],
"workingDirectory": config.get('WorkingDir', '') or '/',
"workingDirectory": config.get('WorkingDir') or '/',
"environment": [{"name": key, "value": value} for (key, value) in env_vars],
"isolators": DockerV1ToACIManifestTranslator._build_isolators(config),
"mountPoints": DockerV1ToACIManifestTranslator._build_volumes(config),
"ports": DockerV1ToACIManifestTranslator._build_ports(config),
"annotations": [
{"name": "created", "value": docker_layer_data.get('created', '')},
{"name": "created", "value": docker_layer_data.get('created') or ''},
{"name": "homepage", "value": source_url},
{"name": "quay.io/derived-image", "value": synthetic_image_id},
]