Browse code

Merge pull request #8392 from jfrazelle/pr_8389

Invalid mount mode for volumes in

Andrea Luzzardi authored on 2014/10/04 09:22:21
Showing 2 changed files
... ...
@@ -235,7 +235,7 @@ func parseVolumesFromSpec(daemon *Daemon, spec string) (map[string]*Mount, error
235 235
 
236 236
 	if len(specParts) == 2 {
237 237
 		mode := specParts[1]
238
-		if validMountMode(mode) {
238
+		if !validMountMode(mode) {
239 239
 			return nil, fmt.Errorf("Invalid mode for volumes-from: %s", mode)
240 240
 		}
241 241
 
... ...
@@ -389,9 +389,19 @@ func TestRunVolumesFromInReadWriteMode(t *testing.T) {
389 389
 		t.Fatal(err)
390 390
 	}
391 391
 
392
+	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:rw", "busybox", "touch", "/test/file")
393
+	if out, _, err := runCommandWithOutput(cmd); err != nil {
394
+		t.Fatalf("running --volumes-from parent:rw failed with output: %q\nerror: %v", out, err)
395
+	}
396
+
397
+	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:bar", "busybox", "touch", "/test/file")
398
+	if out, _, err := runCommandWithOutput(cmd); err == nil || !strings.Contains(out, "Invalid mode for volumes-from: bar") {
399
+		t.Fatalf("running --volumes-from foo:bar should have failed with invalid mount mode: %q", out)
400
+	}
401
+
392 402
 	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent", "busybox", "touch", "/test/file")
393
-	if _, err := runCommand(cmd); err != nil {
394
-		t.Fatal(err)
403
+	if out, _, err := runCommandWithOutput(cmd); err != nil {
404
+		t.Fatalf("running --volumes-from parent failed with output: %q\nerror: %v", out, err)
395 405
 	}
396 406
 
397 407
 	deleteAllContainers()