Browse code

Fix volume error messages

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/10/27 06:19:44
Showing 3 changed files
... ...
@@ -359,11 +359,11 @@ var (
359 359
 		HTTPStatusCode: http.StatusInternalServerError,
360 360
 	})
361 361
 
362
-	// ErrorCodeVolumeInvalidMode is generated when we the mode of a volume/bind
362
+	// ErrorCodeVolumeInvalidMode is generated when the mode of a volume/bind
363 363
 	// mount is invalid.
364 364
 	ErrorCodeVolumeInvalidMode = errcode.Register(errGroup, errcode.ErrorDescriptor{
365 365
 		Value:          "VOLUMEINVALIDMODE",
366
-		Message:        "invalid mode: %s",
366
+		Message:        "invalid mode: %q",
367 367
 		Description:    "An invalid 'mode' was specified",
368 368
 		HTTPStatusCode: http.StatusInternalServerError,
369 369
 	})
... ...
@@ -372,7 +372,7 @@ var (
372 372
 	// volume specification isn't valid.
373 373
 	ErrorCodeVolumeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
374 374
 		Value:          "VOLUMEINVALID",
375
-		Message:        "Invalid volume specification: %s",
375
+		Message:        "Invalid volume specification: '%s'",
376 376
 		Description:    "An invalid 'volume' was specified in the mount request",
377 377
 		HTTPStatusCode: http.StatusInternalServerError,
378 378
 	})
... ...
@@ -380,7 +380,7 @@ var (
380 380
 	// ErrorCodeVolumeAbs is generated when path to a volume isn't absolute.
381 381
 	ErrorCodeVolumeAbs = errcode.Register(errGroup, errcode.ErrorDescriptor{
382 382
 		Value:          "VOLUMEABS",
383
-		Message:        "Invalid volume destination path: %s mount path must be absolute.",
383
+		Message:        "Invalid volume destination path: '%s' mount path must be absolute.",
384 384
 		Description:    "An invalid 'destination' path was specified in the mount request, it must be an absolute path",
385 385
 		HTTPStatusCode: http.StatusInternalServerError,
386 386
 	})
... ...
@@ -388,7 +388,7 @@ var (
388 388
 	// ErrorCodeVolumeName is generated when the name of named volume isn't valid.
389 389
 	ErrorCodeVolumeName = errcode.Register(errGroup, errcode.ErrorDescriptor{
390 390
 		Value:          "VOLUME_NAME_INVALID",
391
-		Message:        "%s includes invalid characters for a local volume name, only %s are allowed",
391
+		Message:        "%q includes invalid characters for a local volume name, only %q are allowed",
392 392
 		Description:    "The name of volume is invalid",
393 393
 		HTTPStatusCode: http.StatusBadRequest,
394 394
 	})
... ...
@@ -417,7 +417,7 @@ var (
417 417
 	// ErrorCodeVolumeSourceNotFound is generated the source directory could not be found (Windows specific)
418 418
 	ErrorCodeVolumeSourceNotFound = errcode.Register(errGroup, errcode.ErrorDescriptor{
419 419
 		Value:          "VOLUMESOURCENOTFOUND",
420
-		Message:        "Source directory '%s' could not be found: %v",
420
+		Message:        "Source directory '%s' could not be found: %s",
421 421
 		HTTPStatusCode: http.StatusInternalServerError,
422 422
 	})
423 423
 
... ...
@@ -431,7 +431,7 @@ var (
431 431
 	// ErrorCodeVolumeFromBlank is generated when path to a volume is blank.
432 432
 	ErrorCodeVolumeFromBlank = errcode.Register(errGroup, errcode.ErrorDescriptor{
433 433
 		Value:          "VOLUMEFROMBLANK",
434
-		Message:        "malformed volumes-from specification: %s",
434
+		Message:        "malformed volumes-from specification: %q",
435 435
 		Description:    "An invalid 'destination' path was specified in the mount request, it must not be blank",
436 436
 		HTTPStatusCode: http.StatusInternalServerError,
437 437
 	})
... ...
@@ -440,7 +440,7 @@ var (
440 440
 	// to the same path.
441 441
 	ErrorCodeVolumeDup = errcode.Register(errGroup, errcode.ErrorDescriptor{
442 442
 		Value:          "VOLUMEDUP",
443
-		Message:        "Duplicate bind mount %s",
443
+		Message:        "Duplicate bind mount '%s'",
444 444
 		Description:    "An attempt was made to mount a volume but the specified destination location is already used in a previous mount",
445 445
 		HTTPStatusCode: http.StatusInternalServerError,
446 446
 	})
... ...
@@ -449,7 +449,7 @@ var (
449 449
 	// for a volume mount was found. (Windows specific)
450 450
 	ErrorCodeVolumeNoSourceForMount = errcode.Register(errGroup, errcode.ErrorDescriptor{
451 451
 		Value:          "VOLUMENOSOURCEFORMOUNT",
452
-		Message:        "No source for mount name %q driver %q destination %s",
452
+		Message:        "No source for mount name '%s' driver %q destination '%s'",
453 453
 		HTTPStatusCode: http.StatusInternalServerError,
454 454
 	})
455 455
 
... ...
@@ -347,8 +347,8 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) {
347 347
 	dockerCmd(c, "run", "--name", "parent", "-v", volumeDir, "busybox", "true")
348 348
 	dockerCmd(c, "run", "--volumes-from", "parent:rw", "busybox", "touch", fileInVol)
349 349
 
350
-	if out, _, err := dockerCmdWithError("run", "--volumes-from", "parent:bar", "busybox", "touch", fileInVol); err == nil || !strings.Contains(out, "invalid mode: bar") {
351
-		c.Fatalf("running --volumes-from parent:bar should have failed with invalid mount mode: %q", out)
350
+	if out, _, err := dockerCmdWithError("run", "--volumes-from", "parent:bar", "busybox", "touch", fileInVol); err == nil || !strings.Contains(out, `invalid mode: "bar"`) {
351
+		c.Fatalf("running --volumes-from parent:bar should have failed with invalid mode: %q", out)
352 352
 	}
353 353
 
354 354
 	dockerCmd(c, "run", "--volumes-from", "parent", "busybox", "touch", fileInVol)
... ...
@@ -111,8 +111,8 @@ func TestParseMountSpec(t *testing.T) {
111 111
 			"/path:ro":        "Invalid volume specification",
112 112
 			"/rw:rw":          "Invalid volume specification",
113 113
 			"path:ro":         "Invalid volume specification",
114
-			"/path:/path:sw":  "invalid mode: sw",
115
-			"/path:/path:rwz": "invalid mode: rwz",
114
+			"/path:/path:sw":  `invalid mode: "sw"`,
115
+			"/path:/path:rwz": `invalid mode: "rwz"`,
116 116
 		}
117 117
 	}
118 118