Merge pull request #2273 from jakedt/fixaci

Fix aci
This commit is contained in:
Jake Moshenko 2017-01-11 15:44:06 -05:00 committed by GitHub
commit 773f271daa
2 changed files with 12 additions and 13 deletions

View file

@ -31,7 +31,7 @@ verbs = Blueprint('verbs', __name__)
license_validator.enforce_license_before_request(verbs)
def _open_stream(formatter, namespace, repository, tag, derived_image_id, repo_image, handlers):
def _open_stream(formatter, repo_image, tag, derived_image_id, handlers):
"""
This method generates a stream of data which will be replicated and read from the queue files.
This method runs in a separate process.
@ -56,8 +56,7 @@ def _open_stream(formatter, namespace, repository, tag, derived_image_id, repo_i
logger.debug('Returning image layer %s: %s', current_image.image_id, current_image_path)
yield current_image_stream
stream = formatter.build_stream(namespace, repository, tag, repo_image, derived_image_id,
get_next_image, get_next_layer)
stream = formatter.build_stream(repo_image, tag, derived_image_id, get_next_image, get_next_layer)
for handler_fn in handlers:
stream = wrap_with_handler(stream, handler_fn)
@ -259,7 +258,7 @@ def _repo_verb(namespace, repository, tag, verb, formatter, sign=False, checker=
# Create a queue process to generate the data. The queue files will read from the process
# and send the results to the client and storage.
handlers = [hasher.update]
args = (formatter, namespace, repository, tag, derived_image_id, repo_image, handlers)
args = (formatter, repo_image, tag, derived_image_id, handlers)
queue_process = QueueProcess(_open_stream,
8 * 1024, 10 * 1024 * 1024, # 8K/10M chunk/max
args, finished=_store_metadata_and_cleanup)

View file

@ -31,8 +31,8 @@ class AppCImageFormatter(TarImageFormatter):
# Yield the manifest.
manifest = json.dumps(DockerV1ToACIManifestTranslator.build_manifest(
tag,
repo_image,
tag,
synthetic_image_id
))
yield self.tar_file('manifest', manifest, mtime=image_mtime)
@ -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},
]