File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,10 +18,12 @@ package containerd
1818
1919import (
2020 "context"
21+ "errors"
2122 "syscall"
2223
2324 "github.com/containerd/containerd/errdefs"
2425 "github.com/containerd/containerd/mount"
26+ specs "github.com/opencontainers/runtime-spec/specs-go"
2527)
2628
2729// NewTaskOpts allows the caller to set options on a new task
@@ -92,3 +94,19 @@ func WithKillExecID(execID string) KillOpts {
9294 return nil
9395 }
9496}
97+
98+ // WithResources sets the provided resources for task updates. Resources must be
99+ // either a *specs.LinuxResources or a *specs.WindowsResources
100+ func WithResources (resources interface {}) UpdateTaskOpts {
101+ return func (ctx context.Context , client * Client , r * UpdateTaskInfo ) error {
102+ switch resources .(type ) {
103+ case * specs.LinuxResources :
104+ case * specs.WindowsResources :
105+ default :
106+ return errors .New ("WithResources requires a *specs.LinuxResources or *specs.WindowsResources" )
107+ }
108+
109+ r .Resources = resources
110+ return nil
111+ }
112+ }
Original file line number Diff line number Diff line change @@ -21,17 +21,8 @@ import (
2121 "errors"
2222
2323 "github.com/containerd/containerd/runtime/linux/runctypes"
24- "github.com/opencontainers/runtime-spec/specs-go"
2524)
2625
27- // WithResources sets the provided resources for task updates
28- func WithResources (resources * specs.LinuxResources ) UpdateTaskOpts {
29- return func (ctx context.Context , client * Client , r * UpdateTaskInfo ) error {
30- r .Resources = resources
31- return nil
32- }
33- }
34-
3526// WithNoNewKeyring causes tasks not to be created with a new keyring for secret storage.
3627// There is an upper limit on the number of keyrings in a linux system
3728func WithNoNewKeyring (ctx context.Context , c * Client , ti * TaskInfo ) error {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments