소스 검색

Fixes bad validMountMode check

Needed to check if the mode was invalid and return error, not valid and
return error.

This didn't get picked up because the existing integration-cli tests
were all either expecting errors when a valid mode was passed in (e.g.
"ro" passed in, we expected an error because it was testing write).  So
modified a test which was testing for "rw" to actually pass in "rw"
instead of assuming the "rw"

Docker-DCO-1.1-Signed-off-by: Brian Goff <bgoff@cpuguy83-mbp.home> (github: cpuguy83)
Brian Goff 10 년 전
부모
커밋
007b4f6340
2개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      daemon/volumes.go
  2. 1 1
      integration-cli/docker_cli_run_test.go

+ 1 - 1
daemon/volumes.go

@@ -235,7 +235,7 @@ func parseVolumesFromSpec(daemon *Daemon, spec string) (map[string]*Mount, error
 
 
 	if len(specParts) == 2 {
 	if len(specParts) == 2 {
 		mode := specParts[1]
 		mode := specParts[1]
-		if validMountMode(mode) {
+		if !validMountMode(mode) {
 			return nil, fmt.Errorf("Invalid mode for volumes-from: %s", mode)
 			return nil, fmt.Errorf("Invalid mode for volumes-from: %s", mode)
 		}
 		}
 
 

+ 1 - 1
integration-cli/docker_cli_run_test.go

@@ -389,7 +389,7 @@ func TestRunVolumesFromInReadWriteMode(t *testing.T) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent", "busybox", "touch", "/test/file")
+	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:rw", "busybox", "touch", "/test/file")
 	if _, err := runCommand(cmd); err != nil {
 	if _, err := runCommand(cmd); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}