WithRestoreRuntime restores the runtime for the container
(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index)
| 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 { |
| 78 | return func(ctx context.Context, client *Client, c *containers.Container) error { |
| 79 | name, ok := index.Annotations[checkpointRuntimeNameLabel] |
| 80 | if !ok { |
| 81 | return ErrRuntimeNameNotFoundInIndex |
| 82 | } |
| 83 | |
| 84 | // restore options if present |
| 85 | m, err := GetIndexByMediaType(index, images.MediaTypeContainerd1CheckpointRuntimeOptions) |
| 86 | if err != nil { |
| 87 | if err != ErrMediaTypeNotFound { |
| 88 | return err |
| 89 | } |
| 90 | } |
| 91 | var options ptypes.Any |
| 92 | if m != nil { |
| 93 | store := client.ContentStore() |
| 94 | data, err := content.ReadBlob(ctx, store, *m) |
| 95 | if err != nil { |
| 96 | return fmt.Errorf("unable to read checkpoint runtime: %w", err) |
| 97 | } |
| 98 | if err := proto.Unmarshal(data, &options); err != nil { |
| 99 | return err |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | c.Runtime = containers.RuntimeInfo{ |
| 104 | Name: name, |
| 105 | Options: &options, |
| 106 | } |
| 107 | return nil |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | // WithRestoreSpec restores the spec from the checkpoint for the container |
| 112 | func WithRestoreSpec(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts { |
nothing calls this directly
no test coverage detected
searching dependent graphs…