From 9f73b8c71807143dbe31d493b2d1d97bf5edc3a8 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 26 Sep 2017 11:24:23 -0400 Subject: [PATCH] Support parsing of named pipes for compose volumes. Signed-off-by: Daniel Nephin --- cli/compose/loader/volume.go | 5 +++++ cli/compose/loader/volume_test.go | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/cli/compose/loader/volume.go b/cli/compose/loader/volume.go index b026cf150f..9c2792e0f7 100644 --- a/cli/compose/loader/volume.go +++ b/cli/compose/loader/volume.go @@ -112,6 +112,11 @@ func isFilePath(source string) bool { return true } + // windows named pipes + if strings.HasPrefix(source, `\\`) { + return true + } + first, nextIndex := utf8.DecodeRuneInString(source) return isWindowsDrive([]rune{first}, rune(source[nextIndex])) } diff --git a/cli/compose/loader/volume_test.go b/cli/compose/loader/volume_test.go index 2f2e50a905..90110133fa 100644 --- a/cli/compose/loader/volume_test.go +++ b/cli/compose/loader/volume_test.go @@ -7,6 +7,7 @@ import ( "github.com/docker/cli/cli/compose/types" "github.com/docker/cli/internal/test/testutil" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestParseVolumeAnonymousVolume(t *testing.T) { @@ -149,6 +150,17 @@ func TestParseVolumeWithRW(t *testing.T) { } } +func TestParseVolumeWindowsNamedPipe(t *testing.T) { + volume, err := ParseVolume(`\\.\pipe\docker_engine:\\.\pipe\inside`) + require.NoError(t, err) + expected := types.ServiceVolumeConfig{ + Type: "bind", + Source: `\\.\pipe\docker_engine`, + Target: `\\.\pipe\inside`, + } + assert.Equal(t, expected, volume) +} + func TestIsFilePath(t *testing.T) { assert.False(t, isFilePath("a界")) }