Change tar stream formatters to be based on tag and manifest, instead of legacy images

This commit is contained in:
Joseph Schorr 2018-08-28 17:30:15 -04:00
parent c92294c218
commit bafab2e734
4 changed files with 21 additions and 55 deletions

View file

@ -18,10 +18,10 @@ class AppCImageFormatter(TarImageFormatter):
Image formatter which produces an tarball according to the AppC specification.
"""
def stream_generator(self, repo_image, tag, synthetic_image_id, get_image_iterator,
def stream_generator(self, tag, manifest, synthetic_image_id, layer_iterator,
tar_stream_getter_iterator, reporter=None):
image_mtime = 0
created = next(get_image_iterator()).v1_metadata.created
created = manifest.created_datetime
if created is not None:
image_mtime = calendar.timegm(created.utctimetuple())
@ -31,8 +31,8 @@ class AppCImageFormatter(TarImageFormatter):
# Yield the manifest.
manifest = json.dumps(DockerV1ToACIManifestTranslator.build_manifest(
repo_image,
tag,
manifest,
synthetic_image_id
))
yield self.tar_file('manifest', manifest, mtime=image_mtime)
@ -170,16 +170,16 @@ class DockerV1ToACIManifestTranslator(object):
return volumes
@staticmethod
def build_manifest(repo_image, tag, synthetic_image_id):
def build_manifest(tag, manifest, synthetic_image_id):
""" Builds an ACI manifest of an existing repository image. """
docker_layer_data = JSONPathDict(repo_image.compat_metadata)
docker_layer_data = JSONPathDict(manifest.leaf_layer.v1_metadata)
config = docker_layer_data['config'] or JSONPathDict({})
namespace = repo_image.repository.namespace_name
repo_name = repo_image.repository.name
namespace = tag.repository.namespace_name
repo_name = tag.repository.name
source_url = "%s://%s/%s/%s:%s" % (app.config['PREFERRED_URL_SCHEME'],
app.config['SERVER_HOSTNAME'],
namespace, repo_name, tag)
namespace, repo_name, tag.name)
# ACI requires that the execution command be absolutely referenced. Therefore, if we find
# a relative command, we give it as an argument to /bin/sh to resolve and execute for us.