Jelajahi Sumber

Disable -v overloading

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
(cherry picked from commit ec5a362fb93358244305067419589f602fd33807)
Arnaud Porterie 10 tahun lalu
induk
melakukan
7da5a7eb66
2 mengubah file dengan 5 tambahan dan 54 penghapusan
  1. 2 24
      daemon/volumes.go
  2. 3 30
      daemon/volumes_unit_test.go

+ 2 - 24
daemon/volumes.go

@@ -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)
-		if bind.Driver == volume.DefaultDriverName {
-			return nil, localMountErr
-		}
-	} else {
-		bind.Source = filepath.Clean(arr[0])
+		return nil, fmt.Errorf("cannot bind mount volume: %s volume paths must be absolute.", spec)
 	}
 	}
 
 
+	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)

+ 3 - 30
daemon/volumes_unit_test.go

@@ -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},
-		{"external/name:/tmp:rw", "", "/tmp", "", "name", "external", true, false},
-		{"external/name:/tmp:ro", "", "/tmp", "", "name", "external", false, false},
+		{"name:/tmp", "external", "/tmp", "", "name", "external", true, true},
+		{"external/name:/tmp:rw", "", "/tmp", "", "name", "external", true, true},
+		{"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},