move rw to opt; make snapshot opt; move to NewContainerOpts

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett
2018-09-17 18:22:36 -04:00
parent 147208061c
commit 4fdf720b84
5 changed files with 152 additions and 187 deletions

View File

@@ -538,11 +538,7 @@ func (c *Client) Restore(ctx context.Context, id string, checkpoint Image, opts
copts := []NewContainerOpts{}
for _, o := range opts {
co, err := o(ctx, id, c, checkpoint, index)
if err != nil {
return nil, err
}
copts = append(copts, co...)
copts = append(copts, o(ctx, id, c, checkpoint, index))
}
ctr, err := c.NewContainer(ctx, id, copts...)
@@ -550,26 +546,6 @@ func (c *Client) Restore(ctx context.Context, id string, checkpoint Image, opts
return nil, err
}
// apply rw layer
info, err := ctr.Info(ctx)
if err != nil {
return nil, err
}
rw, err := GetIndexByMediaType(index, ocispec.MediaTypeImageLayerGzip)
if err != nil {
return nil, err
}
mounts, err := c.SnapshotService(info.Snapshotter).Mounts(ctx, info.SnapshotKey)
if err != nil {
return nil, err
}
if _, err := c.DiffService().Apply(ctx, *rw, mounts); err != nil {
return nil, err
}
return ctr, nil
}