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)
| 203 | // provided mounts. Archive content will be extracted and decompressed if |
| 204 | // necessary. |
| 205 | func (c blockCIMDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts []mount.Mount, opts ...diff.ApplyOpt) (d ocispec.Descriptor, err error) { |
| 206 | if len(mounts) != 1 { |
| 207 | return emptyDesc, fmt.Errorf("number of mounts should always be 1 for CimFS layers: %w", errdefs.ErrInvalidArgument) |
| 208 | } else if mounts[0].Type != mount.BlockCIMMountType { |
| 209 | return emptyDesc, fmt.Errorf("blockCIMDiff does not support layer type %s: %w", mounts[0].Type, errdefs.ErrNotImplemented) |
| 210 | } |
| 211 | |
| 212 | m := mounts[0] |
| 213 | |
| 214 | log.G(ctx).WithFields(logrus.Fields{ |
| 215 | "mount": m, |
| 216 | }).Info("applying blockCIM diff") |
| 217 | |
| 218 | layer, parentLayers, err := parseBlockCIMMount(&m) |
| 219 | if err != nil { |
| 220 | return emptyDesc, err |
| 221 | } |
| 222 | |
| 223 | enableLayerIntegrity := mount.GetEnableLayerIntegrity(&m) |
| 224 | appendVHDFooter := mount.GetAppendVHDFooter(&m) |
| 225 | |
| 226 | // Build import options based on mount configuration |
| 227 | var importOpts []ocicimlayer.BlockCIMLayerImportOpt |
| 228 | importOpts = append(importOpts, ocicimlayer.WithParentLayers(parentLayers)) |
| 229 | |
| 230 | if appendVHDFooter { |
| 231 | importOpts = append(importOpts, ocicimlayer.WithVHDFooter()) |
| 232 | } |
| 233 | |
| 234 | if enableLayerIntegrity { |
| 235 | importOpts = append(importOpts, ocicimlayer.WithLayerIntegrity()) |
| 236 | } |
| 237 | |
| 238 | applyFunc := func(ctx context.Context, r io.Reader) (int64, error) { |
| 239 | return ocicimlayer.ImportBlockCIMLayerWithOpts(ctx, r, layer, importOpts...) |
| 240 | } |
| 241 | |
| 242 | return applyCIMLayerCommon(ctx, desc, c.store, applyFunc, opts...) |
| 243 | |
| 244 | } |
| 245 | |
| 246 | // Compare creates a diff between the given mounts and uploads the result |
| 247 | // to the content store. |
nothing calls this directly
no test coverage detected