Port ctr to use client

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-06-05 16:17:37 -07:00
parent bdf9f5f738
commit 4c1af8fdd8
26 changed files with 526 additions and 1179 deletions

View File

@@ -10,7 +10,9 @@ import (
"strconv"
"strings"
"github.com/containerd/containerd/api/services/containers"
"github.com/containerd/containerd/images"
protobuf "github.com/gogo/protobuf/types"
"github.com/opencontainers/image-spec/specs-go/v1"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
@@ -255,3 +257,17 @@ func WithImageConfig(ctx context.Context, i Image) SpecOpts {
return nil
}
}
func WithSpec(spec *specs.Spec) NewContainerOpts {
return func(ctx context.Context, client *Client, c *containers.Container) error {
data, err := json.Marshal(spec)
if err != nil {
return err
}
c.Spec = &protobuf.Any{
TypeUrl: spec.Version,
Value: data,
}
return nil
}
}