Merge pull request #1100 from crosbymichael/update-task

Implement task update
This commit is contained in:
Derek McGowan
2017-06-27 14:39:45 -07:00
committed by GitHub
15 changed files with 749 additions and 152 deletions

View File

@@ -10,6 +10,7 @@ import (
"strings"
"github.com/containerd/containerd/api/services/containers/v1"
"github.com/containerd/containerd/api/services/tasks/v1"
"github.com/containerd/containerd/images"
protobuf "github.com/gogo/protobuf/types"
"github.com/opencontainers/image-spec/specs-go/v1"
@@ -285,3 +286,17 @@ func WithSpec(spec *specs.Spec) NewContainerOpts {
return nil
}
}
func WithResources(resources *specs.LinuxResources) UpdateTaskOpts {
return func(ctx context.Context, client *Client, r *tasks.UpdateTaskRequest) error {
data, err := json.Marshal(resources)
if err != nil {
return err
}
r.Resources = &protobuf.Any{
TypeUrl: specs.Version,
Value: data,
}
return nil
}
}