MCPcopy Create free account
hub / github.com/containers/image / buildLayerInfosForCopy

Function buildLayerInfosForCopy

storage/storage_src.go:361–383  ·  view source on GitHub ↗

buildLayerInfosForCopy builds a LayerInfosForCopy return value based on manifestInfos from the original manifest, but using layer data which we can actually produce — physicalInfos for non-empty layers, and image.GzippedEmptyLayer for empty ones. (This is split basically only to allow easily unit-te

(manifestInfos []manifest.LayerInfo, physicalInfos []types.BlobInfo)

Source from the content-addressed store, hash-verified

359// and image.GzippedEmptyLayer for empty ones.
360// (This is split basically only to allow easily unit-testing the part that has no dependencies on the external environment.)
361func buildLayerInfosForCopy(manifestInfos []manifest.LayerInfo, physicalInfos []types.BlobInfo) ([]types.BlobInfo, error) {
362 nextPhysical := 0
363 res := make([]types.BlobInfo, len(manifestInfos))
364 for i, mi := range manifestInfos {
365 if mi.EmptyLayer {
366 res[i] = types.BlobInfo{
367 Digest: image.GzippedEmptyLayerDigest,
368 Size: int64(len(image.GzippedEmptyLayer)),
369 MediaType: mi.MediaType,
370 }
371 } else {
372 if nextPhysical >= len(physicalInfos) {
373 return nil, fmt.Errorf("expected more than %d physical layers to exist", len(physicalInfos))
374 }
375 res[i] = physicalInfos[nextPhysical] // FIXME? Should we preserve more data in manifestInfos? Notably the current approach correctly removes zstd:chunked metadata annotations.
376 nextPhysical++
377 }
378 }
379 if nextPhysical != len(physicalInfos) {
380 return nil, fmt.Errorf("used only %d out of %d physical layers", nextPhysical, len(physicalInfos))
381 }
382 return res, nil
383}
384
385// GetSignaturesWithFormat returns the image's signatures. It may use a remote (= slow) service.
386// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve signatures for

Callers 2

LayerInfosForCopyMethod · 0.85

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…