Make sure list_manifest_layers is not callable for manifest lists

This commit is contained in:
Joseph Schorr 2018-12-11 13:10:24 -05:00
parent 7fa60d5802
commit a9b8586423
3 changed files with 10 additions and 6 deletions

View file

@ -199,7 +199,7 @@ class RegistryDataInterface(object):
""" Returns an *ordered list* of the layers found in the manifest, starting at the base
and working towards the leaf, including the associated Blob and its placements
(if specified). The layer information in `layer_info` will be of type
`image.docker.types.ManifestImageLayer`.
`image.docker.types.ManifestImageLayer`. Should not be called for a manifest list.
"""
@abstractmethod
@ -208,7 +208,7 @@ class RegistryDataInterface(object):
""" Returns an *ordered list* of the layers found in the parsed manifest, starting at the base
and working towards the leaf, including the associated Blob and its placements
(if specified). The layer information in `layer_info` will be of type
`image.docker.types.ManifestImageLayer`.
`image.docker.types.ManifestImageLayer`. Should not be called for a manifest list.
"""
@abstractmethod

View file

@ -345,6 +345,8 @@ class SharedModel:
working towards the leaf, including the associated Blob and its placements (if specified).
Returns None if the manifest could not be parsed and validated.
"""
assert not parsed.is_manifest_list
retriever = RepositoryContentRetriever(repo_id, storage)
requires_empty_blob = parsed.get_requires_empty_layer_blob(retriever)

View file

@ -58,8 +58,10 @@ def _manifest_dict(manifest):
if manifest.legacy_image_if_present is not None:
image = image_dict(manifest.legacy_image, with_history=True)
layers = None
if not manifest.is_manifest_list:
layers = registry_model.list_manifest_layers(manifest, storage)
if layers is None and not manifest.is_manifest_list:
if layers is None:
logger.debug('Missing layers for manifest `%s`', manifest.digest)
abort(404)