MCPcopy
hub / github.com/containerd/containerd / WithRestoreImage

Function WithRestoreImage

client/container_restore_opts.go:46–74  ·  view source on GitHub ↗

WithRestoreImage restores the image for the container

(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index)

Source from the content-addressed store, hash-verified

44
45// WithRestoreImage restores the image for the container
46func WithRestoreImage(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts {
47 return func(ctx context.Context, client *Client, c *containers.Container) error {
48 name, ok := index.Annotations[imagespec.AnnotationRefName]
49 if !ok || name == "" {
50 return ErrImageNameNotFoundInIndex
51 }
52 snapshotter, ok := index.Annotations[checkpointSnapshotterNameLabel]
53 if !ok || name == "" {
54 return ErrSnapshotterNameNotFoundInIndex
55 }
56 i, err := client.GetImage(ctx, name)
57 if err != nil {
58 return err
59 }
60
61 diffIDs, err := i.(*image).i.RootFS(ctx, client.ContentStore(), client.platform)
62 if err != nil {
63 return err
64 }
65 parent := identity.ChainID(diffIDs).String()
66 if _, err := client.SnapshotService(snapshotter).Prepare(ctx, id, parent); err != nil {
67 return err
68 }
69 c.Image = i.Name()
70 c.SnapshotKey = id
71 c.Snapshotter = snapshotter
72 return nil
73 }
74}
75
76// WithRestoreRuntime restores the runtime for the container
77func WithRestoreRuntime(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts {

Callers

nothing calls this directly

Calls 7

GetImageMethod · 0.65
RootFSMethod · 0.65
ContentStoreMethod · 0.65
PrepareMethod · 0.65
SnapshotServiceMethod · 0.65
NameMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…