Restore restores a container from a checkpoint
(ctx context.Context, id string, checkpoint Image, opts ...RestoreOpts)
| 594 | |
| 595 | // Restore restores a container from a checkpoint |
| 596 | func (c *Client) Restore(ctx context.Context, id string, checkpoint Image, opts ...RestoreOpts) (Container, error) { |
| 597 | store := c.ContentStore() |
| 598 | index, err := decodeIndex(ctx, store, checkpoint.Target()) |
| 599 | if err != nil { |
| 600 | return nil, err |
| 601 | } |
| 602 | |
| 603 | ctx, done, err := c.WithLease(ctx) |
| 604 | if err != nil { |
| 605 | return nil, err |
| 606 | } |
| 607 | defer done(ctx) |
| 608 | |
| 609 | copts := make([]NewContainerOpts, len(opts)) |
| 610 | for i, o := range opts { |
| 611 | copts[i] = o(ctx, id, c, checkpoint, index) |
| 612 | } |
| 613 | |
| 614 | ctr, err := c.NewContainer(ctx, id, copts...) |
| 615 | if err != nil { |
| 616 | return nil, err |
| 617 | } |
| 618 | |
| 619 | return ctr, nil |
| 620 | } |
| 621 | |
| 622 | func writeIndex(ctx context.Context, index *ocispec.Index, client *Client, ref string) (d ocispec.Descriptor, err error) { |
| 623 | labels := map[string]string{} |
nothing calls this directly
no test coverage detected