WithSnapshot uses an existing root filesystem for the container
(id string)
| 201 | |
| 202 | // WithSnapshot uses an existing root filesystem for the container |
| 203 | func WithSnapshot(id string) NewContainerOpts { |
| 204 | return func(ctx context.Context, client *Client, c *containers.Container) error { |
| 205 | // check that the snapshot exists, if not, fail on creation |
| 206 | var err error |
| 207 | c.Snapshotter, err = client.resolveSnapshotterName(ctx, c.Snapshotter) |
| 208 | if err != nil { |
| 209 | return err |
| 210 | } |
| 211 | s, err := client.getSnapshotter(ctx, c.Snapshotter) |
| 212 | if err != nil { |
| 213 | return err |
| 214 | } |
| 215 | if _, err := s.Mounts(ctx, id); err != nil { |
| 216 | return err |
| 217 | } |
| 218 | c.SnapshotKey = id |
| 219 | return nil |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // WithSnapshotCleanup deletes the rootfs snapshot allocated for the container |
| 224 | func WithSnapshotCleanup(ctx context.Context, client *Client, c containers.Container) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…