MCPcopy
hub / github.com/containerd/containerd / ApplyLayerWithOpts

Function ApplyLayerWithOpts

pkg/rootfs/apply.go:91–111  ·  view source on GitHub ↗

ApplyLayerWithOpts applies a single layer on top of the given provided layer chain, using the provided snapshotter, applier, and apply opts. If the layer was unpacked true is returned, if the layer already exists false is returned.

(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshots.Snapshotter, a diff.Applier, opts []snapshots.Opt, applyOpts []diff.ApplyOpt)

Source from the content-addressed store, hash-verified

89// using the provided snapshotter, applier, and apply opts. If the layer was unpacked true
90// is returned, if the layer already exists false is returned.
91func ApplyLayerWithOpts(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshots.Snapshotter, a diff.Applier, opts []snapshots.Opt, applyOpts []diff.ApplyOpt) (bool, error) {
92 var (
93 chainID = identity.ChainID(append(chain, layer.Diff.Digest)).String()
94 applied bool
95 )
96 if _, err := sn.Stat(ctx, chainID); err != nil {
97 if !errdefs.IsNotFound(err) {
98 return false, fmt.Errorf("failed to stat snapshot %s: %w", chainID, err)
99 }
100
101 if err := applyLayers(ctx, []Layer{layer}, append(chain, layer.Diff.Digest), sn, a, opts, applyOpts); err != nil {
102 if !errdefs.IsAlreadyExists(err) {
103 return false, err
104 }
105 } else {
106 applied = true
107 }
108 }
109 return applied, nil
110
111}
112
113func applyLayers(ctx context.Context, layers []Layer, chain []digest.Digest, sn snapshots.Snapshotter, a diff.Applier, opts []snapshots.Opt, applyOpts []diff.ApplyOpt) error {
114 var (

Callers 2

UnpackMethod · 0.92
ApplyLayerFunction · 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…