1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Allow mount type npipe on Windows

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
This commit is contained in:
Olli Janatuinen 2018-07-06 00:18:49 +03:00 committed by Olli Janatuinen
parent ed392603ac
commit 83d9b9e4d9
3 changed files with 24 additions and 1 deletions

View file

@ -285,6 +285,8 @@ func convertMount(m api.Mount) enginemount.Mount {
mount.Type = enginemount.TypeVolume
case api.MountTypeTmpfs:
mount.Type = enginemount.TypeTmpfs
case api.MountTypeNamedPipe:
mount.Type = enginemount.TypeNamedPipe
}
if m.BindOptions != nil {

View file

@ -11,7 +11,8 @@ import (
func validateMounts(mounts []api.Mount) error {
for _, mount := range mounts {
// Target must always be absolute
if !filepath.IsAbs(mount.Target) {
// except if target is Windows named pipe
if !filepath.IsAbs(mount.Target) && mount.Type != api.MountTypeNamedPipe {
return fmt.Errorf("invalid mount target, must be an absolute path: %s", mount.Target)
}
@ -32,6 +33,10 @@ func validateMounts(mounts []api.Mount) error {
if mount.Source != "" {
return errors.New("invalid tmpfs source, source must be empty")
}
case api.MountTypeNamedPipe:
if mount.Source == "" {
return errors.New("invalid npipe source, source must not be empty")
}
default:
return fmt.Errorf("invalid mount type: %s", mount.Type)
}

View file

@ -1,8 +1,24 @@
// +build windows
package container // import "github.com/docker/docker/daemon/cluster/executor/container"
import (
"strings"
"testing"
"github.com/docker/swarmkit/api"
)
const (
testAbsPath = `c:\foo`
testAbsNonExistent = `c:\some-non-existing-host-path\`
)
func TestControllerValidateMountNamedPipe(t *testing.T) {
if _, err := newTestControllerWithMount(api.Mount{
Type: api.MountTypeNamedPipe,
Source: "",
Target: `\\.\pipe\foo`,
}); err == nil || !strings.Contains(err.Error(), "invalid npipe source, source must not be empty") {
t.Fatalf("expected error, got: %v", err)
}
}