mirror of https://github.com/docker/cli.git
Support parsing of named pipes for compose volumes.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
be8dab26a3
commit
9f73b8c718
|
@ -112,6 +112,11 @@ func isFilePath(source string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// windows named pipes
|
||||||
|
if strings.HasPrefix(source, `\\`) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
first, nextIndex := utf8.DecodeRuneInString(source)
|
first, nextIndex := utf8.DecodeRuneInString(source)
|
||||||
return isWindowsDrive([]rune{first}, rune(source[nextIndex]))
|
return isWindowsDrive([]rune{first}, rune(source[nextIndex]))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/docker/cli/cli/compose/types"
|
"github.com/docker/cli/cli/compose/types"
|
||||||
"github.com/docker/cli/internal/test/testutil"
|
"github.com/docker/cli/internal/test/testutil"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseVolumeAnonymousVolume(t *testing.T) {
|
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) {
|
func TestIsFilePath(t *testing.T) {
|
||||||
assert.False(t, isFilePath("a界"))
|
assert.False(t, isFilePath("a界"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue