MCPcopy
hub / github.com/containerd/containerd / getLayers

Method getLayers

client/image.go:396–422  ·  view source on GitHub ↗
(ctx context.Context, manifest ocispec.Manifest)

Source from the content-addressed store, hash-verified

394}
395
396func (i *image) getLayers(ctx context.Context, manifest ocispec.Manifest) ([]rootfs.Layer, error) {
397 diffIDs, err := i.RootFS(ctx)
398 if err != nil {
399 return nil, fmt.Errorf("failed to resolve rootfs: %w", err)
400 }
401
402 // parse out the image layers from oci artifact layers
403 imageLayers := []ocispec.Descriptor{}
404 for _, ociLayer := range manifest.Layers {
405 if images.IsLayerType(ociLayer.MediaType) {
406 imageLayers = append(imageLayers, ociLayer)
407 }
408 }
409 if len(diffIDs) != len(imageLayers) {
410 return nil, errors.New("mismatched image rootfs and manifest layers")
411 }
412 layers := make([]rootfs.Layer, len(diffIDs))
413 for i := range diffIDs {
414 layers[i].Diff = ocispec.Descriptor{
415 // TODO: derive media type from compressed type
416 MediaType: ocispec.MediaTypeImageLayer,
417 Digest: diffIDs[i],
418 }
419 layers[i].Blob = imageLayers[i]
420 }
421 return layers, nil
422}
423
424func (i *image) checkSnapshotterSupport(ctx context.Context, snapshotterName string,
425 manifest ocispec.Manifest, checkSnapshotterSupport bool) error {

Callers 1

UnpackMethod · 0.95

Calls 2

RootFSMethod · 0.95
IsLayerTypeFunction · 0.92

Tested by

no test coverage detected