Allow for images with artifacts to pull

Signed-off-by: James Sturtevant <jstur@microsoft.com>
This commit is contained in:
James Sturtevant 2023-09-25 22:10:19 +00:00
parent e0e6f870b7
commit a9ba33f8ff

View File

@ -379,7 +379,15 @@ func (i *image) getLayers(ctx context.Context, manifest ocispec.Manifest) ([]roo
if err != nil {
return nil, fmt.Errorf("failed to resolve rootfs: %w", err)
}
if len(diffIDs) != len(manifest.Layers) {
// parse out the image layers from oci artifact layers
imageLayers := []ocispec.Descriptor{}
for _, ociLayer := range manifest.Layers {
if images.IsLayerType(ociLayer.MediaType) {
imageLayers = append(imageLayers, ociLayer)
}
}
if len(diffIDs) != len(imageLayers) {
return nil, errors.New("mismatched image rootfs and manifest layers")
}
layers := make([]rootfs.Layer, len(diffIDs))
@ -389,7 +397,7 @@ func (i *image) getLayers(ctx context.Context, manifest ocispec.Manifest) ([]roo
MediaType: ocispec.MediaTypeImageLayer,
Digest: diffIDs[i],
}
layers[i].Blob = manifest.Layers[i]
layers[i].Blob = imageLayers[i]
}
return layers, nil
}