Merge pull request #560 from dnephin/fix-bind-mount-named-pipe-compose

Support parsing of named pipes for compose volumes
This commit is contained in:
Vincent Demeester 2017-10-03 09:29:13 +02:00 committed by GitHub
commit 448d56a491
2 changed files with 17 additions and 0 deletions

View File

@ -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]))
}

View File

@ -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界"))
}