mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Disable -v overloading
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com> (cherry picked from commit ec5a362fb93358244305067419589f602fd33807)
This commit is contained in:
parent
81fa9feb0c
commit
7da5a7eb66
2 changed files with 5 additions and 54 deletions
|
@ -15,8 +15,6 @@ import (
|
||||||
volumedrivers "github.com/docker/docker/volume/drivers"
|
volumedrivers "github.com/docker/docker/volume/drivers"
|
||||||
)
|
)
|
||||||
|
|
||||||
var localMountErr = fmt.Errorf("Invalid driver: %s driver doesn't support named volumes", volume.DefaultDriverName)
|
|
||||||
|
|
||||||
type mountPoint struct {
|
type mountPoint struct {
|
||||||
Name string
|
Name string
|
||||||
Destination string
|
Destination string
|
||||||
|
@ -74,34 +72,14 @@ func parseBindMount(spec string, config *runconfig.Config) (*mountPoint, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !filepath.IsAbs(arr[0]) {
|
if !filepath.IsAbs(arr[0]) {
|
||||||
bind.Driver, bind.Name = parseNamedVolumeInfo(arr[0], config)
|
return nil, fmt.Errorf("cannot bind mount volume: %s volume paths must be absolute.", spec)
|
||||||
if bind.Driver == volume.DefaultDriverName {
|
|
||||||
return nil, localMountErr
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bind.Source = filepath.Clean(arr[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bind.Source = filepath.Clean(arr[0])
|
||||||
bind.Destination = filepath.Clean(bind.Destination)
|
bind.Destination = filepath.Clean(bind.Destination)
|
||||||
return bind, nil
|
return bind, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseNamedVolumeInfo(info string, config *runconfig.Config) (driver string, name string) {
|
|
||||||
p := strings.SplitN(info, "/", 2)
|
|
||||||
switch len(p) {
|
|
||||||
case 2:
|
|
||||||
driver = p[0]
|
|
||||||
name = p[1]
|
|
||||||
default:
|
|
||||||
if driver = config.VolumeDriver; len(driver) == 0 {
|
|
||||||
driver = volume.DefaultDriverName
|
|
||||||
}
|
|
||||||
name = p[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseVolumesFrom(spec string) (string, string, error) {
|
func parseVolumesFrom(spec string) (string, string, error) {
|
||||||
if len(spec) == 0 {
|
if len(spec) == 0 {
|
||||||
return "", "", fmt.Errorf("malformed volumes-from specification: %s", spec)
|
return "", "", fmt.Errorf("malformed volumes-from specification: %s", spec)
|
||||||
|
|
|
@ -8,33 +8,6 @@ import (
|
||||||
volumedrivers "github.com/docker/docker/volume/drivers"
|
volumedrivers "github.com/docker/docker/volume/drivers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseNamedVolumeInfo(t *testing.T) {
|
|
||||||
cases := []struct {
|
|
||||||
driver string
|
|
||||||
name string
|
|
||||||
expDriver string
|
|
||||||
expName string
|
|
||||||
}{
|
|
||||||
{"", "name", "local", "name"},
|
|
||||||
{"external", "name", "external", "name"},
|
|
||||||
{"", "external/name", "external", "name"},
|
|
||||||
{"ignored", "external/name", "external", "name"},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range cases {
|
|
||||||
conf := &runconfig.Config{VolumeDriver: c.driver}
|
|
||||||
driver, name := parseNamedVolumeInfo(c.name, conf)
|
|
||||||
|
|
||||||
if driver != c.expDriver {
|
|
||||||
t.Fatalf("Expected %s, was %s\n", c.expDriver, driver)
|
|
||||||
}
|
|
||||||
|
|
||||||
if name != c.expName {
|
|
||||||
t.Fatalf("Expected %s, was %s\n", c.expName, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseBindMount(t *testing.T) {
|
func TestParseBindMount(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
bind string
|
bind string
|
||||||
|
@ -51,9 +24,9 @@ func TestParseBindMount(t *testing.T) {
|
||||||
{"/tmp:/tmp:rw", "", "/tmp", "/tmp", "", "", true, false},
|
{"/tmp:/tmp:rw", "", "/tmp", "/tmp", "", "", true, false},
|
||||||
{"/tmp:/tmp:foo", "", "/tmp", "/tmp", "", "", false, true},
|
{"/tmp:/tmp:foo", "", "/tmp", "/tmp", "", "", false, true},
|
||||||
{"name:/tmp", "", "", "", "", "", false, true},
|
{"name:/tmp", "", "", "", "", "", false, true},
|
||||||
{"name:/tmp", "external", "/tmp", "", "name", "external", true, false},
|
{"name:/tmp", "external", "/tmp", "", "name", "external", true, true},
|
||||||
{"external/name:/tmp:rw", "", "/tmp", "", "name", "external", true, false},
|
{"external/name:/tmp:rw", "", "/tmp", "", "name", "external", true, true},
|
||||||
{"external/name:/tmp:ro", "", "/tmp", "", "name", "external", false, false},
|
{"external/name:/tmp:ro", "", "/tmp", "", "name", "external", false, true},
|
||||||
{"external/name:/tmp:foo", "", "/tmp", "", "name", "external", false, true},
|
{"external/name:/tmp:foo", "", "/tmp", "", "name", "external", false, true},
|
||||||
{"name:/tmp", "local", "", "", "", "", false, true},
|
{"name:/tmp", "local", "", "", "", "", false, true},
|
||||||
{"local/name:/tmp:rw", "", "", "", "", "", true, true},
|
{"local/name:/tmp:rw", "", "", "", "", "", true, true},
|
||||||
|
|
Loading…
Reference in a new issue