Add root mounts to task info
Add WithRootFS for task creation Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
73bec3edea
commit
c7cc6ad2b4
17
container.go
17
container.go
@ -11,6 +11,7 @@ import (
|
||||
"github.com/containerd/containerd/api/types"
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/typeurl"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
@ -154,6 +155,13 @@ func (c *container) Image(ctx context.Context) (Image, error) {
|
||||
|
||||
type NewTaskOpts func(context.Context, *Client, *TaskInfo) error
|
||||
|
||||
func WithRootFS(mounts []mount.Mount) NewTaskOpts {
|
||||
return func(ctx context.Context, c *Client, ti *TaskInfo) error {
|
||||
ti.RootFS = mounts
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *container) NewTask(ctx context.Context, ioCreate IOCreation, opts ...NewTaskOpts) (Task, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
@ -188,6 +196,15 @@ func (c *container) NewTask(ctx context.Context, ioCreate IOCreation, opts ...Ne
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if info.RootFS != nil {
|
||||
for _, m := range info.RootFS {
|
||||
request.Rootfs = append(request.Rootfs, &types.Mount{
|
||||
Type: m.Type,
|
||||
Source: m.Source,
|
||||
Options: m.Options,
|
||||
})
|
||||
}
|
||||
}
|
||||
if info.Options != nil {
|
||||
any, err := typeurl.MarshalAny(info.Options)
|
||||
if err != nil {
|
||||
|
2
task.go
2
task.go
@ -16,6 +16,7 @@ import (
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/linux/runcopts"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/rootfs"
|
||||
"github.com/containerd/containerd/typeurl"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
@ -55,6 +56,7 @@ type CheckpointTaskOpts func(*CheckpointTaskInfo) error
|
||||
|
||||
type TaskInfo struct {
|
||||
Checkpoint *types.Descriptor
|
||||
RootFS []mount.Mount
|
||||
Options interface{}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user