MCPcopy
hub / github.com/containerd/containerd / withNewSnapshot

Function withNewSnapshot

client/container_opts.go:252–285  ·  view source on GitHub ↗
(id string, i Image, readonly bool, opts ...snapshots.Opt)

Source from the content-addressed store, hash-verified

250}
251
252func withNewSnapshot(id string, i Image, readonly bool, opts ...snapshots.Opt) NewContainerOpts {
253 return func(ctx context.Context, client *Client, c *containers.Container) error {
254 diffIDs, err := i.RootFS(ctx)
255 if err != nil {
256 return err
257 }
258
259 parent := identity.ChainID(diffIDs).String()
260 c.Snapshotter, err = client.resolveSnapshotterName(ctx, c.Snapshotter)
261 if err != nil {
262 return err
263 }
264 s, err := client.getSnapshotter(ctx, c.Snapshotter)
265 if err != nil {
266 return err
267 }
268 parent, err = resolveSnapshotOptions(ctx, client, c.Snapshotter, s, parent, opts...)
269 if err != nil {
270 return err
271 }
272
273 if readonly {
274 _, err = s.View(ctx, id, parent, opts...)
275 } else {
276 _, err = s.Prepare(ctx, id, parent, opts...)
277 }
278 if err != nil {
279 return err
280 }
281 c.SnapshotKey = id
282 c.Image = i.Name()
283 return nil
284 }
285}
286
287// WithContainerExtension appends extension data to the container object.
288// Use this to decorate the container object with additional data for the client

Callers 2

WithNewSnapshotFunction · 0.85
WithNewSnapshotViewFunction · 0.85

Calls 8

resolveSnapshotOptionsFunction · 0.70
RootFSMethod · 0.65
ViewMethod · 0.65
PrepareMethod · 0.65
NameMethod · 0.65
StringMethod · 0.45
getSnapshotterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…