Skip to content

Commit b7c597e

Browse files
committed
api/t/ctr: deprecate DefaultNetworkSettings
This struct is only used to report the networking state for the default bridge network when the container is connected to it. It was deprecated in v1.09 (API v1.21), and scheduled for removal in v1.11. Unfortunately, the deprecation warning was wrongly formatted in the Go code. However, deprecation warnings are already present in swagger.yaml, so don't touch it. Signed-off-by: Albin Kerouanton <[email protected]>
1 parent d0de293 commit b7c597e

7 files changed

Lines changed: 85 additions & 35 deletions

File tree

api/docs/CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -986,9 +986,10 @@ are not part of the underlying image's Config, and deprecated:
986986
* `GET /containers/(name)/json` now accepts a `size` parameter. Setting this parameter to '1' returns container size information in the `SizeRw` and `SizeRootFs` fields.
987987
* `GET /containers/(name)/json` now returns a `NetworkSettings.Networks` field,
988988
detailing network settings per network. This field deprecates the
989-
`NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
990-
`NetworkSettings.IPPrefixLen`, and `NetworkSettings.MacAddress` fields, which
991-
are still returned for backward-compatibility, but will be removed in a future version.
989+
`NetworkSettings.EndpointID`, `NetworkSettings.Gateway`, `NetworkSettings.GlobalIPv6Address`,
990+
`NetworkSettings.GlobalIPv6PrefixLen` `NetworkSettings.IPAddress`, `NetworkSettings.IPPrefixLen`,
991+
`NetworkSettings.IPv6Gateway`, `NetworkSettings.MacAddress` fields, which are
992+
still returned for backward-compatibility, but will be removed in a future version.
992993
* `GET /exec/(id)/json` now returns a `NetworkSettings.Networks` field,
993994
detailing networksettings per network. This field deprecates the
994995
`NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,

api/types/container/network_settings.go

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,44 @@ type NetworkSettingsBase struct {
3737
SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release.
3838
}
3939

40-
// DefaultNetworkSettings holds network information
41-
// during the 2 release deprecation period.
42-
// It will be removed in Docker 1.11.
40+
// DefaultNetworkSettings holds the networking state for the default bridge, if the container is connected to that
41+
// network.
42+
//
43+
// Deprecated: this struct is deprecated since Docker v1.11 and will be removed in v29. You should look for the default
44+
// network in NetworkSettings.Networks instead.
4345
type DefaultNetworkSettings struct {
44-
EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox
45-
Gateway string // Gateway holds the gateway address for the network
46-
GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address
47-
GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
48-
IPAddress string // IPAddress holds the IPv4 address for the network
49-
IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address
50-
IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6
51-
MacAddress string // MacAddress holds the MAC address for the network
46+
// EndpointID uniquely represents a service endpoint in a Sandbox
47+
//
48+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
49+
EndpointID string
50+
// Gateway holds the gateway address for the network
51+
//
52+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
53+
Gateway string
54+
// GlobalIPv6Address holds network's global IPv6 address
55+
//
56+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
57+
GlobalIPv6Address string
58+
// GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
59+
//
60+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
61+
GlobalIPv6PrefixLen int
62+
// IPAddress holds the IPv4 address for the network
63+
//
64+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
65+
IPAddress string
66+
// IPPrefixLen represents mask length of network's IPv4 address
67+
//
68+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
69+
IPPrefixLen int
70+
// IPv6Gateway holds gateway address specific for IPv6
71+
//
72+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
73+
IPv6Gateway string
74+
// MacAddress holds the MAC address for the network
75+
//
76+
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
77+
MacAddress string
5278
}
5379

5480
// NetworkSettingsSummary provides a summary of container's networks

daemon/inspect.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, err
242242

243243
// getDefaultNetworkSettings creates the deprecated structure that holds the information
244244
// about the bridge network for a container.
245-
func getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) containertypes.DefaultNetworkSettings {
245+
func getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) containertypes.DefaultNetworkSettings { //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
246246
nw, ok := networks[networktypes.NetworkBridge]
247247
if !ok || nw.EndpointSettings == nil {
248-
return containertypes.DefaultNetworkSettings{}
248+
return containertypes.DefaultNetworkSettings{} //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
249249
}
250250

251-
return containertypes.DefaultNetworkSettings{
251+
return containertypes.DefaultNetworkSettings{ //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
252252
EndpointID: nw.EndpointSettings.EndpointID,
253253
Gateway: nw.EndpointSettings.Gateway,
254254
GlobalIPv6Address: nw.EndpointSettings.GlobalIPv6Address,

integration-cli/docker_api_inspect_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ func (s *DockerAPISuite) TestInspectAPIBridgeNetworkSettings121(c *testing.T) {
103103
assert.NilError(c, err)
104104

105105
settings := inspectJSON.NetworkSettings
106-
assert.Assert(c, settings.IPAddress != "")
107106
assert.Assert(c, settings.Networks["bridge"] != nil)
108-
assert.Equal(c, settings.IPAddress, settings.Networks["bridge"].IPAddress)
107+
assert.Assert(c, settings.Networks["bridge"].IPAddress != "")
109108
}

integration-cli/docker_cli_network_unix_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,9 +1045,6 @@ func (s *DockerCLINetworkSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
10451045
err := json.Unmarshal(body, &inspectCurrent)
10461046
assert.NilError(c, err)
10471047
assert.Equal(c, len(inspectCurrent.NetworkSettings.Networks), 3)
1048-
1049-
bridge := inspectCurrent.NetworkSettings.Networks["bridge"]
1050-
assert.Equal(c, bridge.IPAddress, inspectCurrent.NetworkSettings.IPAddress)
10511048
}
10521049

10531050
func connectContainerToNetworks(t *testing.T, d *daemon.Daemon, cName string, nws []string) {

integration/networking/etchosts_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ ff02::2 ip6-allrouters
9797
stdout := runCmd(ctrId, []string{"cat", "/etc/hosts"}, 0)
9898
// Append the container's own addresses/name to the expected hosts file content.
9999
inspect := container.Inspect(ctx, t, c, ctrId)
100-
exp := tc.expEtcHosts + inspect.NetworkSettings.IPAddress + "\t" + inspect.Config.Hostname + "\n"
100+
bridgeEp := inspect.NetworkSettings.Networks["bridge"]
101+
exp := tc.expEtcHosts + bridgeEp.IPAddress + "\t" + inspect.Config.Hostname + "\n"
101102
if tc.expIPv6Enabled {
102-
exp += inspect.NetworkSettings.GlobalIPv6Address + "\t" + inspect.Config.Hostname + "\n"
103+
exp += bridgeEp.GlobalIPv6Address + "\t" + inspect.Config.Hostname + "\n"
103104
}
104105
assert.Check(t, is.Equal(stdout, exp))
105106
})

vendor/github.com/moby/moby/api/types/container/network_settings.go

Lines changed: 37 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)