Fix conversion of schema 2 manifests to schema 1 manifests

Also adds a number of conversion tests and clarify the interfaces a bit more
This commit is contained in:
Joseph Schorr 2018-11-21 17:23:52 +02:00
parent bd79eaa38f
commit c233760007
11 changed files with 457 additions and 183 deletions

View file

@ -215,14 +215,6 @@ class DockerSchema2ManifestList(ManifestInterface):
def layers(self):
return None
@property
def leaf_layer_v1_image_id(self):
return None
@property
def legacy_image_ids(self):
return None
@property
def blob_digests(self):
# Manifest lists have no blob digests, since everything is stored as a manifest.
@ -253,7 +245,17 @@ class DockerSchema2ManifestList(ManifestInterface):
def get_manifest_labels(self, content_retriever):
return None
def get_v1_compatible_manifest(self, namespace_name, repo_name, tag_name, content_retriever):
def get_leaf_layer_v1_image_id(self, content_retriever):
return None
def get_legacy_image_ids(self, content_retriever):
return None
@property
def has_legacy_image(self):
return False
def get_schema1_manifest(self, namespace_name, repo_name, tag_name, content_retriever):
""" Returns the manifest that is compatible with V1, by virtue of being `amd64` and `linux`.
If none, returns None.
"""
@ -270,8 +272,7 @@ class DockerSchema2ManifestList(ManifestInterface):
logger.exception('Could not load child manifest')
return None
return manifest.get_v1_compatible_manifest(namespace_name, repo_name, tag_name,
content_retriever)
return manifest.get_schema1_manifest(namespace_name, repo_name, tag_name, content_retriever)
return None