Browse code

Stop referring CLI flags in error messages if API client is unknown

Signed-off-by: Stanislav Bondarenko <stanislav.bondarenko@gmail.com>

Stanislav Bondarenko authored on 2017/05/22 02:50:55
Showing 8 changed files
... ...
@@ -77,7 +77,7 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui
77 77
 	}
78 78
 
79 79
 	if runtime.GOOS != "windows" && options.SecurityOpt != nil {
80
-		return nil, fmt.Errorf("the daemon on this platform does not support --security-opt to build")
80
+		return nil, fmt.Errorf("The daemon on this platform does not support setting security options on build")
81 81
 	}
82 82
 
83 83
 	var buildUlimits = []*units.Ulimit{}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 var (
14
-	errExperimentalFeature = errors.New("This experimental feature is disabled by default. Start the Docker daemon with --experimental in order to enable it.")
14
+	errExperimentalFeature = errors.New("This experimental feature is disabled by default. Start the Docker daemon in experimental mode in order to enable it.")
15 15
 )
16 16
 
17 17
 // ExperimentalRoute defines an experimental API route that can be enabled or disabled.
... ...
@@ -44,7 +44,7 @@ func (s *DockerSuite) TestNetHostname(c *check.C) {
44 44
 	c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkHostname.Error())
45 45
 
46 46
 	out, _ = dockerCmdWithFail(c, "run", "--net=container", "busybox", "ps")
47
-	c.Assert(out, checker.Contains, "--net: invalid net mode: invalid container format container:<name|id>")
47
+	c.Assert(out, checker.Contains, "Invalid network mode: invalid container format container:<name|id>")
48 48
 
49 49
 	out, _ = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps")
50 50
 	c.Assert(out, checker.Contains, "network weird not found")
... ...
@@ -75,9 +75,9 @@ func TestDecodeContainerConfig(t *testing.T) {
75 75
 // as to what level of container isolation is supported.
76 76
 func TestDecodeContainerConfigIsolation(t *testing.T) {
77 77
 
78
-	// An invalid isolation level
78
+	// An Invalid isolation level
79 79
 	if _, _, _, err := callDecodeContainerConfigIsolation("invalid"); err != nil {
80
-		if !strings.Contains(err.Error(), `invalid --isolation: "invalid"`) {
80
+		if !strings.Contains(err.Error(), `Invalid isolation: "invalid"`) {
81 81
 			t.Fatal(err)
82 82
 		}
83 83
 	}
... ...
@@ -99,7 +99,7 @@ func TestDecodeContainerConfigIsolation(t *testing.T) {
99 99
 		}
100 100
 	} else {
101 101
 		if _, _, _, err := callDecodeContainerConfigIsolation("process"); err != nil {
102
-			if !strings.Contains(err.Error(), `invalid --isolation: "process"`) {
102
+			if !strings.Contains(err.Error(), `Invalid isolation: "process"`) {
103 103
 				t.Fatal(err)
104 104
 			}
105 105
 		}
... ...
@@ -112,7 +112,7 @@ func TestDecodeContainerConfigIsolation(t *testing.T) {
112 112
 		}
113 113
 	} else {
114 114
 		if _, _, _, err := callDecodeContainerConfigIsolation("hyperv"); err != nil {
115
-			if !strings.Contains(err.Error(), `invalid --isolation: "hyperv"`) {
115
+			if !strings.Contains(err.Error(), `Invalid isolation: "hyperv"`) {
116 116
 				t.Fatal(err)
117 117
 			}
118 118
 		}
... ...
@@ -45,7 +45,7 @@ func validateNetContainerMode(c *container.Config, hc *container.HostConfig) err
45 45
 	parts := strings.Split(string(hc.NetworkMode), ":")
46 46
 	if parts[0] == "container" {
47 47
 		if len(parts) < 2 || parts[1] == "" {
48
-			return fmt.Errorf("--net: invalid net mode: invalid container format container:<name|id>")
48
+			return fmt.Errorf("Invalid network mode: invalid container format container:<name|id>")
49 49
 		}
50 50
 	}
51 51
 
... ...
@@ -55,7 +55,7 @@ func validateIsolation(hc *container.HostConfig) error {
55 55
 		return nil
56 56
 	}
57 57
 	if !hc.Isolation.IsValid() {
58
-		return fmt.Errorf("invalid --isolation: %q - %s only supports 'default'", hc.Isolation, runtime.GOOS)
58
+		return fmt.Errorf("Invalid isolation: %q - %s only supports 'default'", hc.Isolation, runtime.GOOS)
59 59
 	}
60 60
 	return nil
61 61
 }
... ...
@@ -68,11 +68,11 @@ func validateQoS(hc *container.HostConfig) error {
68 68
 	}
69 69
 
70 70
 	if hc.IOMaximumBandwidth != 0 {
71
-		return fmt.Errorf("invalid QoS settings: %s does not support --io-maxbandwidth", runtime.GOOS)
71
+		return fmt.Errorf("Invalid QoS settings: %s does not support configuration of maximum bandwidth", runtime.GOOS)
72 72
 	}
73 73
 
74 74
 	if hc.IOMaximumIOps != 0 {
75
-		return fmt.Errorf("invalid QoS settings: %s does not support --io-maxiops", runtime.GOOS)
75
+		return fmt.Errorf("Invalid QoS settings: %s does not support configuration of maximum IOPs", runtime.GOOS)
76 76
 	}
77 77
 	return nil
78 78
 }
... ...
@@ -86,15 +86,15 @@ func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
86 86
 	}
87 87
 
88 88
 	if hc.Resources.CPURealtimePeriod > 0 && !si.CPURealtimePeriod {
89
-		return fmt.Errorf("invalid --cpu-rt-period: Your kernel does not support cgroup rt period")
89
+		return fmt.Errorf("Your kernel does not support cgroup cpu real-time period")
90 90
 	}
91 91
 
92 92
 	if hc.Resources.CPURealtimeRuntime > 0 && !si.CPURealtimeRuntime {
93
-		return fmt.Errorf("invalid --cpu-rt-runtime: Your kernel does not support cgroup rt runtime")
93
+		return fmt.Errorf("Your kernel does not support cgroup cpu real-time runtime")
94 94
 	}
95 95
 
96 96
 	if hc.Resources.CPURealtimePeriod != 0 && hc.Resources.CPURealtimeRuntime != 0 && hc.Resources.CPURealtimeRuntime > hc.Resources.CPURealtimePeriod {
97
-		return fmt.Errorf("invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period")
97
+		return fmt.Errorf("cpu real-time runtime cannot be higher than cpu real-time period")
98 98
 	}
99 99
 	return nil
100 100
 }
... ...
@@ -31,7 +31,7 @@ func validateNetMode(c *container.Config, hc *container.HostConfig) error {
31 31
 	}
32 32
 
33 33
 	if hc.NetworkMode.IsContainer() && hc.Isolation.IsHyperV() {
34
-		return fmt.Errorf("net mode --net=container:<NameOrId> unsupported for hyperv isolation")
34
+		return fmt.Errorf("Using the network stack of another container is not supported while using Hyper-V Containers")
35 35
 	}
36 36
 
37 37
 	return nil
... ...
@@ -46,7 +46,7 @@ func validateIsolation(hc *container.HostConfig) error {
46 46
 		return nil
47 47
 	}
48 48
 	if !hc.Isolation.IsValid() {
49
-		return fmt.Errorf("invalid --isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation)
49
+		return fmt.Errorf("Invalid isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation)
50 50
 	}
51 51
 	return nil
52 52
 }
... ...
@@ -63,10 +63,10 @@ func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
63 63
 		return nil
64 64
 	}
65 65
 	if hc.Resources.CPURealtimePeriod != 0 {
66
-		return fmt.Errorf("invalid --cpu-rt-period: Windows does not support this feature")
66
+		return fmt.Errorf("Windows does not support CPU real-time period")
67 67
 	}
68 68
 	if hc.Resources.CPURealtimeRuntime != 0 {
69
-		return fmt.Errorf("invalid --cpu-rt-runtime: Windows does not support this feature")
69
+		return fmt.Errorf("Windows does not support CPU real-time runtime")
70 70
 	}
71 71
 	return nil
72 72
 }
... ...
@@ -78,7 +78,7 @@ func validatePrivileged(hc *container.HostConfig) error {
78 78
 		return nil
79 79
 	}
80 80
 	if hc.Privileged {
81
-		return fmt.Errorf("invalid --privileged: Windows does not support this feature")
81
+		return fmt.Errorf("Windows does not support privileged mode")
82 82
 	}
83 83
 	return nil
84 84
 }
... ...
@@ -90,7 +90,7 @@ func validateReadonlyRootfs(hc *container.HostConfig) error {
90 90
 		return nil
91 91
 	}
92 92
 	if hc.ReadonlyRootfs {
93
-		return fmt.Errorf("invalid --read-only: Windows does not support this feature")
93
+		return fmt.Errorf("Windows does not support root filesystem in read-only mode")
94 94
 	}
95 95
 	return nil
96 96
 }
... ...
@@ -9,7 +9,7 @@ import (
9 9
 )
10 10
 
11 11
 func TestValidatePrivileged(t *testing.T) {
12
-	expected := "invalid --privileged: Windows does not support this feature"
12
+	expected := "Windows does not support privileged mode"
13 13
 	err := validatePrivileged(&container.HostConfig{Privileged: true})
14 14
 	if err == nil || err.Error() != expected {
15 15
 		t.Fatalf("Expected %s", expected)