Fix usage of oci in other packages.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin
2017-11-22 15:45:47 -05:00
parent 081f8c7ce0
commit cdf62f69a1
13 changed files with 80 additions and 68 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/oci"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -21,8 +22,8 @@ func init() {
})
}
func withLayers(context *cli.Context) containerd.SpecOpts {
return func(ctx gocontext.Context, client *containerd.Client, c *containers.Container, s *specs.Spec) error {
func withLayers(context *cli.Context) oci.SpecOpts {
return func(ctx gocontext.Context, client oci.Client, c *containers.Container, s *specs.Spec) error {
l := context.StringSlice("layer")
if l == nil {
return errors.Wrap(errdefs.ErrInvalidArgument, "base layers must be specified with `--layer`")
@@ -32,9 +33,9 @@ func withLayers(context *cli.Context) containerd.SpecOpts {
}
}
func withTTY(terminal bool) containerd.SpecOpts {
func withTTY(terminal bool) oci.SpecOpts {
if !terminal {
return func(ctx gocontext.Context, client *containerd.Client, c *containers.Container, s *specs.Spec) error {
return func(ctx gocontext.Context, client oci.Client, c *containers.Container, s *specs.Spec) error {
s.Process.Terminal = false
return nil
}
@@ -45,7 +46,7 @@ func withTTY(terminal bool) containerd.SpecOpts {
if err != nil {
logrus.WithError(err).Error("console size")
}
return containerd.WithTTY(int(size.Width), int(size.Height))
return oci.WithTTY(int(size.Width), int(size.Height))
}
func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli.Context) (containerd.Container, error) {
@@ -61,18 +62,18 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli
// TODO(mlaventure): get base image once we have a snapshotter
opts := []containerd.SpecOpts{
// TODO(mlaventure): use containerd.WithImageConfig once we have a snapshotter
opts := []oci.SpecOpts{
// TODO(mlaventure): use oci.WithImageConfig once we have a snapshotter
withLayers(context),
withEnv(context),
withMounts(context),
withTTY(tty),
}
if len(args) > 0 {
opts = append(opts, containerd.WithProcessArgs(args...))
opts = append(opts, oci.WithProcessArgs(args...))
}
if cwd := context.String("cwd"); cwd != "" {
opts = append(opts, containerd.WithProcessCwd(cwd))
opts = append(opts, oci.WithProcessCwd(cwd))
}
return client.NewContainer(ctx, id,
containerd.WithNewSpec(opts...),