Skip to content

Commit 92291a7

Browse files
committed
Stop referring CLI flags in error messages if API client is unknown
Signed-off-by: Stanislav Bondarenko <[email protected]>
1 parent 916e9ad commit 92291a7

8 files changed

Lines changed: 21 additions & 21 deletions

File tree

api/server/router/build/build_routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui
7777
}
7878

7979
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")
8181
}
8282

8383
var buildUlimits = []*units.Ulimit{}

api/server/router/experimental.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
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.")
1515
)
1616

1717
// ExperimentalRoute defines an experimental API route that can be enabled or disabled.

integration-cli/docker_cli_netmode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (s *DockerSuite) TestNetHostname(c *check.C) {
4444
c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkHostname.Error())
4545

4646
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>")
4848

4949
out, _ = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps")
5050
c.Assert(out, checker.Contains, "network weird not found")

runconfig/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ func TestDecodeContainerConfig(t *testing.T) {
7575
// as to what level of container isolation is supported.
7676
func TestDecodeContainerConfigIsolation(t *testing.T) {
7777

78-
// An invalid isolation level
78+
// An Invalid isolation level
7979
if _, _, _, err := callDecodeContainerConfigIsolation("invalid"); err != nil {
80-
if !strings.Contains(err.Error(), `invalid --isolation: "invalid"`) {
80+
if !strings.Contains(err.Error(), `Invalid isolation: "invalid"`) {
8181
t.Fatal(err)
8282
}
8383
}
@@ -99,7 +99,7 @@ func TestDecodeContainerConfigIsolation(t *testing.T) {
9999
}
100100
} else {
101101
if _, _, _, err := callDecodeContainerConfigIsolation("process"); err != nil {
102-
if !strings.Contains(err.Error(), `invalid --isolation: "process"`) {
102+
if !strings.Contains(err.Error(), `Invalid isolation: "process"`) {
103103
t.Fatal(err)
104104
}
105105
}
@@ -112,7 +112,7 @@ func TestDecodeContainerConfigIsolation(t *testing.T) {
112112
}
113113
} else {
114114
if _, _, _, err := callDecodeContainerConfigIsolation("hyperv"); err != nil {
115-
if !strings.Contains(err.Error(), `invalid --isolation: "hyperv"`) {
115+
if !strings.Contains(err.Error(), `Invalid isolation: "hyperv"`) {
116116
t.Fatal(err)
117117
}
118118
}

runconfig/hostconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func validateNetContainerMode(c *container.Config, hc *container.HostConfig) err
4545
parts := strings.Split(string(hc.NetworkMode), ":")
4646
if parts[0] == "container" {
4747
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>")
4949
}
5050
}
5151

runconfig/hostconfig_unix.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func validateIsolation(hc *container.HostConfig) error {
5555
return nil
5656
}
5757
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)
5959
}
6060
return nil
6161
}
@@ -68,11 +68,11 @@ func validateQoS(hc *container.HostConfig) error {
6868
}
6969

7070
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)
7272
}
7373

7474
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)
7676
}
7777
return nil
7878
}
@@ -86,15 +86,15 @@ func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
8686
}
8787

8888
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")
9090
}
9191

9292
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")
9494
}
9595

9696
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")
9898
}
9999
return nil
100100
}

runconfig/hostconfig_windows.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func validateNetMode(c *container.Config, hc *container.HostConfig) error {
3131
}
3232

3333
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")
3535
}
3636

3737
return nil
@@ -46,7 +46,7 @@ func validateIsolation(hc *container.HostConfig) error {
4646
return nil
4747
}
4848
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)
5050
}
5151
return nil
5252
}
@@ -63,10 +63,10 @@ func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
6363
return nil
6464
}
6565
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")
6767
}
6868
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")
7070
}
7171
return nil
7272
}
@@ -78,7 +78,7 @@ func validatePrivileged(hc *container.HostConfig) error {
7878
return nil
7979
}
8080
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")
8282
}
8383
return nil
8484
}
@@ -90,7 +90,7 @@ func validateReadonlyRootfs(hc *container.HostConfig) error {
9090
return nil
9191
}
9292
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")
9494
}
9595
return nil
9696
}

runconfig/hostconfig_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func TestValidatePrivileged(t *testing.T) {
12-
expected := "invalid --privileged: Windows does not support this feature"
12+
expected := "Windows does not support privileged mode"
1313
err := validatePrivileged(&container.HostConfig{Privileged: true})
1414
if err == nil || err.Error() != expected {
1515
t.Fatalf("Expected %s", expected)

0 commit comments

Comments
 (0)