Merge WithResources for Linux/Windows TaskOpts

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
Justin Terry (VM)
2018-08-30 12:35:08 -07:00
parent 777cc50c72
commit c48f8dec1f
3 changed files with 18 additions and 40 deletions

View File

@@ -18,10 +18,12 @@ package containerd
import (
"context"
"errors"
"syscall"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/mount"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
// NewTaskOpts allows the caller to set options on a new task
@@ -92,3 +94,19 @@ func WithKillExecID(execID string) KillOpts {
return nil
}
}
// WithResources sets the provided resources for task updates. Resources must be
// either a *specs.LinuxResources or a *specs.WindowsResources
func WithResources(resources interface{}) UpdateTaskOpts {
return func(ctx context.Context, client *Client, r *UpdateTaskInfo) error {
switch resources.(type) {
case *specs.LinuxResources:
case *specs.WindowsResources:
default:
return errors.New("WithResources requires a *specs.LinuxResources or *specs.WindowsResources")
}
r.Resources = resources
return nil
}
}