From e35b025aa61e7d8db04a9973967b7109f742593a Mon Sep 17 00:00:00 2001 From: jhowardmsft Date: Fri, 24 Apr 2015 11:12:56 -0700 Subject: [PATCH] Windows: Split ContainerExecCreate Signed-off-by: John Howard --- daemon/exec.go | 6 +++--- daemon/exec_linux.go | 18 ++++++++++++++++++ daemon/exec_windows.go | 9 +++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 daemon/exec_linux.go create mode 100644 daemon/exec_windows.go diff --git a/daemon/exec.go b/daemon/exec.go index 5febf083a6..fc4e8eab4e 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -9,7 +9,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" - "github.com/docker/docker/daemon/execdriver/lxc" "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/stringid" @@ -111,8 +110,9 @@ func (d *Daemon) getActiveContainer(name string) (*Container, error) { func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, error) { - if strings.HasPrefix(d.execDriver.Name(), lxc.DriverName) { - return "", lxc.ErrExec + // Not all drivers support Exec (LXC for example) + if err := checkExecSupport(d.execDriver.Name()); err != nil { + return "", err } container, err := d.getActiveContainer(config.Container) diff --git a/daemon/exec_linux.go b/daemon/exec_linux.go new file mode 100644 index 0000000000..a360326327 --- /dev/null +++ b/daemon/exec_linux.go @@ -0,0 +1,18 @@ +// +build linux + +package daemon + +import ( + "strings" + + "github.com/docker/docker/daemon/execdriver/lxc" +) + +// checkExecSupport returns an error if the exec driver does not support exec, +// or nil if it is supported. +func checkExecSupport(drivername string) error { + if strings.HasPrefix(drivername, lxc.DriverName) { + return lxc.ErrExec + } + return nil +} diff --git a/daemon/exec_windows.go b/daemon/exec_windows.go new file mode 100644 index 0000000000..d6f244e6d6 --- /dev/null +++ b/daemon/exec_windows.go @@ -0,0 +1,9 @@ +// +build windows + +package daemon + +// checkExecSupport returns an error if the exec driver does not support exec, +// or nil if it is supported. +func checkExecSupport(DriverName string) error { + return nil +}