WithRestoreImage restores the image for the container
(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index)
| 44 | |
| 45 | // WithRestoreImage restores the image for the container |
| 46 | func 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 |
| 77 | func WithRestoreRuntime(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts { |
nothing calls this directly
no test coverage detected
searching dependent graphs…