Browse code

integration-cli: remove uses of "runconfig"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/07/21 04:02:38
Showing 5 changed files
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"testing"
12 12
 
13 13
 	"github.com/docker/docker/api/types/versions"
14
-	"github.com/docker/docker/runconfig"
15 14
 	"github.com/docker/docker/testutil"
16 15
 	"github.com/docker/docker/testutil/request"
17 16
 	"gotest.tools/v3/assert"
... ...
@@ -79,7 +78,7 @@ func (s *DockerAPISuite) TestAPIErrorJSON(c *testing.T) {
79 79
 	assert.Assert(c, is.Contains(httpResp.Header.Get("Content-Type"), "application/json"))
80 80
 	b, err := request.ReadBody(body)
81 81
 	assert.NilError(c, err)
82
-	assert.Equal(c, getErrorMessage(c, b), runconfig.ErrEmptyConfig.Error())
82
+	assert.Check(c, is.Contains(getErrorMessage(c, b), "config cannot be empty"))
83 83
 }
84 84
 
85 85
 func (s *DockerAPISuite) TestAPIErrorNotFoundJSON(c *testing.T) {
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"testing"
11 11
 
12 12
 	"github.com/docker/docker/integration-cli/cli"
13
-	"github.com/docker/docker/runconfig"
14 13
 	"gotest.tools/v3/assert"
15 14
 	is "gotest.tools/v3/assert/cmp"
16 15
 )
... ...
@@ -225,7 +224,7 @@ func (s *DockerCLILinksSuite) TestLinksNetworkHostContainer(c *testing.T) {
225 225
 	// Running container linking to a container with --net host should have failed
226 226
 	assert.Check(c, err != nil, "out: %s", out)
227 227
 	// Running container linking to a container with --net host should have failed
228
-	assert.Check(c, is.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error()))
228
+	assert.Check(c, is.Contains(out, "conflicting options: host type networking can't be used with links. This would result in undefined behavior"))
229 229
 }
230 230
 
231 231
 func (s *DockerCLILinksSuite) TestLinksEtcHostsRegularFile(c *testing.T) {
... ...
@@ -6,7 +6,6 @@ import (
6 6
 	"testing"
7 7
 
8 8
 	"github.com/docker/docker/integration-cli/cli"
9
-	"github.com/docker/docker/runconfig"
10 9
 	"gotest.tools/v3/assert"
11 10
 	is "gotest.tools/v3/assert/cmp"
12 11
 )
... ...
@@ -55,7 +54,7 @@ func (s *DockerCLINetmodeSuite) TestNetHostname(c *testing.T) {
55 55
 	out = cli.DockerCmd(c, "run", "-h=name", "--net=none", "busybox", "ps").Stdout()
56 56
 	assert.Assert(c, is.Contains(out, stringCheckPS))
57 57
 	out = dockerCmdWithFail(c, "run", "-h=name", "--net=container:other", "busybox", "ps")
58
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictNetworkHostname.Error()))
58
+	assert.Assert(c, is.Contains(out, "conflicting options: hostname and the network mode"))
59 59
 	out = dockerCmdWithFail(c, "run", "--net=container", "busybox", "ps")
60 60
 	assert.Assert(c, is.Contains(out, "invalid container format container:<name|id>"))
61 61
 	out = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps")
... ...
@@ -66,34 +65,34 @@ func (s *DockerCLINetmodeSuite) TestConflictContainerNetworkAndLinks(c *testing.
66 66
 	testRequires(c, DaemonIsLinux)
67 67
 
68 68
 	out := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps")
69
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictContainerNetworkAndLinks.Error()))
69
+	assert.Assert(c, is.Contains(out, "conflicting options: container type network can't be used with links"))
70 70
 }
71 71
 
72 72
 func (s *DockerCLINetmodeSuite) TestConflictContainerNetworkHostAndLinks(c *testing.T) {
73 73
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
74 74
 
75 75
 	out := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps")
76
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error()))
76
+	assert.Assert(c, is.Contains(out, "conflicting options: host type networking can't be used with links"))
77 77
 }
78 78
 
79 79
 func (s *DockerCLINetmodeSuite) TestConflictNetworkModeNetHostAndOptions(c *testing.T) {
80 80
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
81 81
 
82 82
 	out := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
83
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error()))
83
+	assert.Assert(c, is.Contains(out, "conflicting options: mac-address and the network mode"))
84 84
 }
85 85
 
86 86
 func (s *DockerCLINetmodeSuite) TestConflictNetworkModeAndOptions(c *testing.T) {
87 87
 	testRequires(c, DaemonIsLinux)
88 88
 
89 89
 	out := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps")
90
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictNetworkAndDNS.Error()))
90
+	assert.Assert(c, is.Contains(out, "conflicting options: dns and the network mode"))
91 91
 	out = dockerCmdWithFail(c, "run", "--net=container:other", "--add-host=name:8.8.8.8", "busybox", "ps")
92
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictNetworkHosts.Error()))
92
+	assert.Assert(c, is.Contains(out, "conflicting options: custom host-to-IP mapping and the network mode"))
93 93
 	out = dockerCmdWithFail(c, "run", "--net=container:other", "-P", "busybox", "ps")
94
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
94
+	assert.Assert(c, is.Contains(out, "conflicting options: port publishing and the container type network mode"))
95 95
 	out = dockerCmdWithFail(c, "run", "--net=container:other", "-p", "8080", "busybox", "ps")
96
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
96
+	assert.Assert(c, is.Contains(out, "conflicting options: port publishing and the container type network mode"))
97 97
 	out = dockerCmdWithFail(c, "run", "--net=container:other", "--expose", "8000-9000", "busybox", "ps")
98
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictNetworkExposePorts.Error()))
98
+	assert.Assert(c, is.Contains(out, "conflicting options: port exposing and the container type network mode"))
99 99
 }
... ...
@@ -26,7 +26,6 @@ import (
26 26
 	"github.com/docker/docker/internal/nlwrap"
27 27
 	"github.com/docker/docker/pkg/plugins"
28 28
 	"github.com/docker/docker/pkg/stringid"
29
-	"github.com/docker/docker/runconfig"
30 29
 	"github.com/docker/docker/testutil"
31 30
 	testdaemon "github.com/docker/docker/testutil/daemon"
32 31
 	"github.com/vishvananda/netlink"
... ...
@@ -1155,7 +1154,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *t
1155 1155
 	cli.DockerCmd(c, "network", "disconnect", "bridge", "container1")
1156 1156
 	out, _, err := dockerCmdWithError("network", "connect", "host", "container1")
1157 1157
 	assert.ErrorContains(c, err, "", out)
1158
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictConnectToHostNetwork.Error()))
1158
+	assert.Assert(c, is.Contains(out, "cannot connect container to host network"))
1159 1159
 }
1160 1160
 
1161 1161
 func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) {
... ...
@@ -1163,7 +1162,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) {
1163 1163
 	cli.WaitRun(c, "container1")
1164 1164
 	out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1")
1165 1165
 	assert.Assert(c, err != nil, "Should err out disconnect from host")
1166
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictDisconnectFromHostNetwork.Error()))
1166
+	assert.Assert(c, is.Contains(out, "cannot disconnect container from host network"))
1167 1167
 }
1168 1168
 
1169 1169
 func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing.T) {
... ...
@@ -1324,7 +1323,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) {
1324 1324
 	// Still it should fail to connect to the default network with a specified IP (whatever ip)
1325 1325
 	out, _, err := dockerCmdWithError("network", "connect", "--ip", "172.21.55.44", "bridge", "c0")
1326 1326
 	assert.Assert(c, err != nil, "out: %s", out)
1327
-	assert.Assert(c, is.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error()))
1327
+	assert.Assert(c, is.Contains(out, "user specified IP address is supported on user defined networks only"))
1328 1328
 }
1329 1329
 
1330 1330
 func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer(c *testing.T) {
... ...
@@ -1362,10 +1361,10 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T
1362 1362
 
1363 1363
 	out, _, err := dockerCmdWithError("run", "-d", "--ip", "172.28.99.88", "--net", "n0", "busybox", "top")
1364 1364
 	assert.Assert(c, err != nil, "out: %s", out)
1365
-	assert.Assert(c, is.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()))
1365
+	assert.Assert(c, is.Contains(out, "user specified IP address is supported only when connecting to networks with user configured subnets"))
1366 1366
 	out, _, err = dockerCmdWithError("run", "-d", "--ip6", "2001:db8:1234::9988", "--net", "n0", "busybox", "top")
1367 1367
 	assert.Assert(c, err != nil, "out: %s", out)
1368
-	assert.Assert(c, is.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()))
1368
+	assert.Assert(c, is.Contains(out, "user specified IP address is supported only when connecting to networks with user configured subnets"))
1369 1369
 	cli.DockerCmd(c, "network", "rm", "n0")
1370 1370
 	assertNwNotAvailable(c, "n0")
1371 1371
 }
... ...
@@ -1373,7 +1372,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T
1373 1373
 func checkUnsupportedNetworkAndIP(t *testing.T, nwMode string) {
1374 1374
 	out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
1375 1375
 	assert.Assert(t, err != nil, "out: %s", out)
1376
-	assert.Assert(t, is.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error()))
1376
+	assert.Assert(t, is.Contains(out, "user specified IP address is supported on user defined networks only"))
1377 1377
 }
1378 1378
 
1379 1379
 func verifyIPAddressConfig(t *testing.T, cName, nwname, ipv4, ipv6 string) {
... ...
@@ -1512,7 +1511,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(
1512 1512
 	for _, nw := range defaults {
1513 1513
 		res, _, err := dockerCmdWithError("network", "connect", "--alias", "alias"+nw, nw, containerID)
1514 1514
 		assert.ErrorContains(c, err, "")
1515
-		assert.Assert(c, is.Contains(res, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
1515
+		assert.Assert(c, is.Contains(res, "network-scoped alias is supported only for containers in user defined networks"))
1516 1516
 	}
1517 1517
 }
1518 1518
 
... ...
@@ -1563,11 +1562,11 @@ func (s *DockerCLINetworkSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *
1563 1563
 	// verify the alias option is rejected when running on predefined network
1564 1564
 	out, _, err := dockerCmdWithError("run", "--rm", "--name=any", "--net-alias=any", "busybox:glibc", "true")
1565 1565
 	assert.Assert(c, err != nil, "out: %s", out)
1566
-	assert.Assert(c, is.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
1566
+	assert.Assert(c, is.Contains(out, "network-scoped alias is supported only for containers in user defined networks"))
1567 1567
 	// verify the alias option is rejected when connecting to predefined network
1568 1568
 	out, _, err = dockerCmdWithError("network", "connect", "--alias=any", "bridge", "first")
1569 1569
 	assert.Assert(c, err != nil, "out: %s", out)
1570
-	assert.Assert(c, is.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
1570
+	assert.Assert(c, is.Contains(out, "network-scoped alias is supported only for containers in user defined networks"))
1571 1571
 }
1572 1572
 
1573 1573
 func (s *DockerCLINetworkSuite) TestUserDefinedNetworkConnectivity(c *testing.T) {
... ...
@@ -30,7 +30,6 @@ import (
30 30
 	"github.com/docker/docker/integration-cli/daemon"
31 31
 	"github.com/docker/docker/internal/testutils/specialimage"
32 32
 	"github.com/docker/docker/pkg/stringid"
33
-	"github.com/docker/docker/runconfig"
34 33
 	"github.com/docker/docker/testutil"
35 34
 	testdaemon "github.com/docker/docker/testutil/daemon"
36 35
 	"github.com/docker/docker/testutil/fakecontext"
... ...
@@ -293,7 +292,7 @@ func (s *DockerCLIRunSuite) TestRunWithNetAliasOnDefaultNetworks(c *testing.T) {
293 293
 	for _, nw := range defaults {
294 294
 		out, _, err := dockerCmdWithError("run", "-d", "--net", nw, "--net-alias", "alias_"+nw, "busybox", "top")
295 295
 		assert.ErrorContains(c, err, "")
296
-		assert.Assert(c, is.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
296
+		assert.Assert(c, is.Contains(out, "network-scoped alias is supported only for containers in user defined networks"))
297 297
 	}
298 298
 }
299 299
 
... ...
@@ -2429,7 +2428,7 @@ func (s *DockerCLIRunSuite) TestRunModeUTSHost(c *testing.T) {
2429 2429
 	}
2430 2430
 
2431 2431
 	out = dockerCmdWithFail(c, "run", "-h=name", "--uts=host", "busybox", "ps")
2432
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictUTSHostname.Error()))
2432
+	assert.Assert(c, is.Contains(out, "conflicting options: hostname and the UTS mode"))
2433 2433
 }
2434 2434
 
2435 2435
 func (s *DockerCLIRunSuite) TestRunTLSVerify(c *testing.T) {
... ...
@@ -3297,12 +3296,12 @@ func (s *DockerCLIRunSuite) TestRunContainerNetModeWithDNSMacHosts(c *testing.T)
3297 3297
 	}
3298 3298
 
3299 3299
 	out, _, err = dockerCmdWithError("run", "--dns", "1.2.3.4", "--net=container:parent", "busybox")
3300
-	if err == nil || !strings.Contains(out, runconfig.ErrConflictNetworkAndDNS.Error()) {
3300
+	if err == nil || !strings.Contains(out, "conflicting options: dns and the network mode") {
3301 3301
 		c.Fatalf("run --net=container with --dns should error out")
3302 3302
 	}
3303 3303
 
3304 3304
 	out, _, err = dockerCmdWithError("run", "--add-host", "test:192.168.2.109", "--net=container:parent", "busybox")
3305
-	if err == nil || !strings.Contains(out, runconfig.ErrConflictNetworkHosts.Error()) {
3305
+	if err == nil || !strings.Contains(out, "conflicting options: custom host-to-IP mapping and the network mode") {
3306 3306
 		c.Fatalf("run --net=container with --add-host should error out")
3307 3307
 	}
3308 3308
 }
... ...
@@ -3313,17 +3312,17 @@ func (s *DockerCLIRunSuite) TestRunContainerNetModeWithExposePort(c *testing.T)
3313 3313
 	cli.DockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top")
3314 3314
 
3315 3315
 	out, _, err := dockerCmdWithError("run", "-p", "5000:5000", "--net=container:parent", "busybox")
3316
-	if err == nil || !strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()) {
3316
+	if err == nil || !strings.Contains(out, "conflicting options: port publishing and the container type network mode") {
3317 3317
 		c.Fatalf("run --net=container with -p should error out")
3318 3318
 	}
3319 3319
 
3320 3320
 	out, _, err = dockerCmdWithError("run", "-P", "--net=container:parent", "busybox")
3321
-	if err == nil || !strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()) {
3321
+	if err == nil || !strings.Contains(out, "conflicting options: port publishing and the container type network mode") {
3322 3322
 		c.Fatalf("run --net=container with -P should error out")
3323 3323
 	}
3324 3324
 
3325 3325
 	out, _, err = dockerCmdWithError("run", "--expose", "5000", "--net=container:parent", "busybox")
3326
-	if err == nil || !strings.Contains(out, runconfig.ErrConflictNetworkExposePorts.Error()) {
3326
+	if err == nil || !strings.Contains(out, "conflicting options: port exposing and the container type network mode") {
3327 3327
 		c.Fatalf("run --net=container with --expose should error out")
3328 3328
 	}
3329 3329
 }
... ...
@@ -3538,7 +3537,7 @@ func (s *DockerCLIRunSuite) TestContainerWithConflictingSharedNetwork(c *testing
3538 3538
 	// Connecting to the user defined network must fail
3539 3539
 	out, _, err := dockerCmdWithError("network", "connect", "testnetwork1", "second")
3540 3540
 	assert.ErrorContains(c, err, "")
3541
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictSharedNetwork.Error()))
3541
+	assert.Assert(c, is.Contains(out, "container sharing network namespace with another container or host cannot be connected to any other network"))
3542 3542
 }
3543 3543
 
3544 3544
 func (s *DockerCLIRunSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) {
... ...
@@ -3552,7 +3551,7 @@ func (s *DockerCLIRunSuite) TestContainerWithConflictingNoneNetwork(c *testing.T
3552 3552
 	// Connecting to the user defined network must fail
3553 3553
 	out, _, err := dockerCmdWithError("network", "connect", "testnetwork1", "first")
3554 3554
 	assert.ErrorContains(c, err, "")
3555
-	assert.Assert(c, is.Contains(out, runconfig.ErrConflictNoNetwork.Error()))
3555
+	assert.Assert(c, is.Contains(out, "container cannot be connected to multiple networks with one of the networks in private (none) mode"))
3556 3556
 	// create a container connected to testnetwork1
3557 3557
 	cli.DockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
3558 3558
 	cli.WaitRun(c, "second")