MCPcopy
hub / github.com/containerd/containerd / ApplyLayersWithOpts

Function ApplyLayersWithOpts

pkg/rootfs/apply.go:57–79  ·  view source on GitHub ↗

ApplyLayersWithOpts applies all the layers using the given snapshotter, applier, and apply opts. The returned result is a chain id digest representing all the applied layers. Layers are applied in order they are given, making the first layer the bottom-most layer in the layer chain.

(ctx context.Context, layers []Layer, sn snapshots.Snapshotter, a diff.Applier, applyOpts []diff.ApplyOpt)

Source from the content-addressed store, hash-verified

55// Layers are applied in order they are given, making the first layer the
56// bottom-most layer in the layer chain.
57func ApplyLayersWithOpts(ctx context.Context, layers []Layer, sn snapshots.Snapshotter, a diff.Applier, applyOpts []diff.ApplyOpt) (digest.Digest, error) {
58 chain := make([]digest.Digest, len(layers))
59 for i, layer := range layers {
60 chain[i] = layer.Diff.Digest
61 }
62 chainID := identity.ChainID(chain)
63
64 // Just stat top layer, remaining layers will have their existence checked
65 // on prepare. Calling prepare on upper layers first guarantees that upper
66 // layers are not removed while calling stat on lower layers
67 _, err := sn.Stat(ctx, chainID.String())
68 if err != nil {
69 if !errdefs.IsNotFound(err) {
70 return "", fmt.Errorf("failed to stat snapshot %s: %w", chainID, err)
71 }
72
73 if err := applyLayers(ctx, layers, chain, sn, a, nil, applyOpts); err != nil && !errdefs.IsAlreadyExists(err) {
74 return "", err
75 }
76 }
77
78 return chainID, nil
79}
80
81// ApplyLayer applies a single layer on top of the given provided layer chain,
82// using the provided snapshotter and applier. If the layer was unpacked true

Callers 1

ApplyLayersFunction · 0.85

Calls 3

applyLayersFunction · 0.85
StatMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…