Add support for retargeting a tag to all schema 1 manifests

Schema version 1 manifests contain the tag name, and we have a check to ensure we don't point a tag at a manifest with the wrong name embedded. However, this also means that we cannot retarget to that manifest, which will break the UI once we get rid of legacy images.

This change means we can retarget to those manifests, and the OCI model does the work of rewriting the manifest when necessary.
This commit is contained in:
Joseph Schorr 2019-01-15 16:00:06 -05:00
parent a1caefcabe
commit 570d974067
3 changed files with 56 additions and 0 deletions

View file

@ -356,6 +356,15 @@ class DockerSchema1Manifest(ManifestInterface):
return builder.build()
def with_tag_name(self, tag_name, json_web_key=None):
""" Returns a copy of this manifest, with the tag changed to the given tag name. """
builder = DockerSchema1ManifestBuilder(self._namespace, self._repo_name, tag_name,
self._architecture)
for layer in reversed(self.layers):
builder.add_layer(str(layer.digest), layer.raw_v1_metadata)
return builder.build(json_web_key)
def _generate_layers(self):
"""
Returns a generator of objects that have the blobSum and v1Compatibility keys in them,