WithCheckpointTask includes the running task
(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions)
| 54 | |
| 55 | // WithCheckpointTask includes the running task |
| 56 | func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error { |
| 57 | opt, err := typeurl.MarshalAnyToProto(copts) |
| 58 | if err != nil { |
| 59 | return nil |
| 60 | } |
| 61 | task, err := client.TaskService().Checkpoint(ctx, &tasks.CheckpointTaskRequest{ |
| 62 | ContainerID: c.ID, |
| 63 | Options: opt, |
| 64 | }) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | for _, d := range task.Descriptors { |
| 69 | platformSpec := platforms.DefaultSpec() |
| 70 | index.Manifests = append(index.Manifests, imagespec.Descriptor{ |
| 71 | MediaType: d.MediaType, |
| 72 | Size: d.Size, |
| 73 | Digest: digest.Digest(d.Digest), |
| 74 | Platform: &platformSpec, |
| 75 | Annotations: d.Annotations, |
| 76 | }) |
| 77 | } |
| 78 | // save copts |
| 79 | data, err := proto.Marshal(opt) |
| 80 | if err != nil { |
| 81 | return err |
| 82 | } |
| 83 | r := bytes.NewReader(data) |
| 84 | desc, err := writeContent(ctx, client.ContentStore(), images.MediaTypeContainerd1CheckpointOptions, c.ID+"-checkpoint-options", r) |
| 85 | if err != nil { |
| 86 | return err |
| 87 | } |
| 88 | desc.Platform = &imagespec.Platform{ |
| 89 | OS: runtime.GOOS, |
| 90 | Architecture: runtime.GOARCH, |
| 91 | } |
| 92 | index.Manifests = append(index.Manifests, desc) |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | // WithCheckpointRuntime includes the container runtime info |
| 97 | func WithCheckpointRuntime(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…