MCPcopy
hub / github.com/containerd/containerd / Apply

Method Apply

plugins/diff/windows/cimfs.go:113–139  ·  view source on GitHub ↗

Apply applies the content associated with the provided digests onto the provided mounts. Archive content will be extracted and decompressed if necessary.

(ctx context.Context, desc ocispec.Descriptor, mounts []mount.Mount, opts ...diff.ApplyOpt)

Source from the content-addressed store, hash-verified

111// provided mounts. Archive content will be extracted and decompressed if
112// necessary.
113func (c cimDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts []mount.Mount, opts ...diff.ApplyOpt) (d ocispec.Descriptor, err error) {
114 if len(mounts) != 1 {
115 return emptyDesc, fmt.Errorf("number of mounts should always be 1 for CimFS layers: %w", errdefs.ErrInvalidArgument)
116 } else if mounts[0].Type != mount.CimFSMountType {
117 return emptyDesc, fmt.Errorf("cimDiff does not support layer type %s: %w", mounts[0].Type, errdefs.ErrNotImplemented)
118 }
119
120 m := mounts[0]
121 parentLayerPaths, err := m.GetParentPaths()
122 if err != nil {
123 return emptyDesc, err
124 }
125 parentLayerCimPaths, err := mount.GetParentCimPaths(&m)
126 if err != nil {
127 return emptyDesc, err
128 }
129 cimPath, err := mount.GetCimPath(&m)
130 if err != nil {
131 return emptyDesc, err
132 }
133
134 applyFunc := func(fCtx context.Context, r io.Reader) (int64, error) {
135 return ocicimlayer.ImportCimLayerFromTar(fCtx, r, m.Source, cimPath, parentLayerPaths, parentLayerCimPaths)
136 }
137
138 return applyCIMLayerCommon(ctx, desc, c.store, applyFunc, opts...)
139}
140
141// Compare creates a diff between the given mounts and uploads the result
142// to the content store.

Callers

nothing calls this directly

Calls 4

GetParentCimPathsFunction · 0.92
GetCimPathFunction · 0.92
applyCIMLayerCommonFunction · 0.85
GetParentPathsMethod · 0.80

Tested by

no test coverage detected