Merge pull request #2208 from jessvalarezo/windows-runtime-platform

windows: define platform in runtime plugin init
This commit is contained in:
Derek McGowan 2018-03-13 19:58:25 -07:00 committed by GitHub
commit 8fc382cba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,11 +33,13 @@ import (
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/windows/hcsshimtypes" "github.com/containerd/containerd/windows/hcsshimtypes"
"github.com/containerd/typeurl" "github.com/containerd/typeurl"
specs "github.com/opencontainers/runtime-spec/specs-go" imagespec "github.com/opencontainers/image-spec/specs-go/v1"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -66,6 +68,8 @@ func init() {
// New returns a new Windows runtime // New returns a new Windows runtime
func New(ic *plugin.InitContext) (interface{}, error) { func New(ic *plugin.InitContext) (interface{}, error) {
ic.Meta.Platforms = []imagespec.Platform{platforms.DefaultSpec()}
if err := os.MkdirAll(ic.Root, 0700); err != nil { if err := os.MkdirAll(ic.Root, 0700); err != nil {
return nil, errors.Wrapf(err, "could not create state directory at %s", ic.Root) return nil, errors.Wrapf(err, "could not create state directory at %s", ic.Root)
} }
@ -114,7 +118,7 @@ func (r *windowsRuntime) Create(ctx context.Context, id string, opts runtime.Cre
if err != nil { if err != nil {
return nil, err return nil, err
} }
spec := s.(*specs.Spec) spec := s.(*runtimespec.Spec)
var createOpts *hcsshimtypes.CreateOptions var createOpts *hcsshimtypes.CreateOptions
if opts.Options != nil { if opts.Options != nil {
@ -218,7 +222,7 @@ func (r *windowsRuntime) Delete(ctx context.Context, t runtime.Task) (*runtime.E
return rtExit, nil return rtExit, nil
} }
func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, rootfs []mount.Mount, spec *specs.Spec, io runtime.IO, createOpts *hcsshimtypes.CreateOptions) (*task, error) { func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, rootfs []mount.Mount, spec *runtimespec.Spec, io runtime.IO, createOpts *hcsshimtypes.CreateOptions) (*task, error) {
var ( var (
err error err error
pset *pipeSet pset *pipeSet