8000 Merge pull request #50839 from akerouanton/28.x-deprecate-NetworkSett… · moby/moby@ee15931 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee15931

Browse files
authored
Merge pull request #50839 from akerouanton/28.x-deprecate-NetworkSettingsBase
[28.x] deprecate NetworkSettingsBase, DefaultNetworkSettings
2 parents 02b4a1a + 660b67b commit ee15931

File tree

11 files changed

+65
-40
lines changed

11 files changed

+65
-40
lines changed

api/swagger.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,8 @@ definitions:
16081608
Bridge:
16091609
description: |
16101610
Name of the default bridge interface when dockerd's --bridge flag is set.
1611+
1612+
Deprecated: This field is only set when the daemon is started with the --bridge flag specified.
16111613
type: "string"
16121614
example: "docker0"
16131615
SandboxID:

api/types/container/network_settings.go

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ type NetworkSettings struct {
1313
}
1414

1515
// NetworkSettingsBase holds networking state for a container when inspecting it.
16+
//
17+
// Deprecated: Most fields in NetworkSettingsBase are deprecated. Fields which aren't deprecated will move to
18+
// NetworkSettings in v29.0, and this struct will be removed.
1619
type NetworkSettingsBase struct {
17-
Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag.
20+
Bridge string // Deprecated: This field is only set when the daemon is started with the --bridge flag specified.
1821
SandboxID string // SandboxID uniquely represents a container's network stack
1922
SandboxKey string // SandboxKey identifies the sandbox
2023
Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port
@@ -35,18 +38,44 @@ type NetworkSettingsBase struct {
3538
SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release.
3639
}
3740

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

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

api/types/types_deprecated.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ type NetworkSettings = container.NetworkSettings
4646

4747
// NetworkSettingsBase holds networking state for a container when inspecting it.
4848
//
49-
// Deprecated: use [container.NetworkSettingsBase].
50-
type NetworkSettingsBase = container.NetworkSettingsBase
49+
// Deprecated: [container.NetworkSettingsBase] will be removed in v29. Prefer
50+
// accessing the fields it contains through [container.NetworkSettings].
51+
type NetworkSettingsBase = container.NetworkSettingsBase //nolint:staticcheck // ignore SA1019: NetworkSettingsBase is deprecated in v28.4.
5152

5253
// DefaultNetworkSettings holds network information
5354
// during the 2 release deprecation period.
5455
// It will be removed in Docker 1.11.
5556
//
5657
// Deprecated: use [container.DefaultNetworkSettings].
57-
type DefaultNetworkSettings = container.DefaultNetworkSettings
58+
type DefaultNetworkSettings = container.DefaultNetworkSettings //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
5859

5960
// SummaryNetworkSettings provides a summary of container's networks
6061
// in /containers/json.

daemon/inspect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (daemon *Daemon) ContainerInspect(ctx context.Context, name string, options
4747

4848
mountPoints := ctr.GetMountPoints()
4949
networkSettings := &containertypes.NetworkSettings{
50-
NetworkSettingsBase: containertypes.NetworkSettingsBase{
50+
NetworkSettingsBase: containertypes.NetworkSettingsBase{ //nolint:staticcheck // ignore SA1019: NetworkSettingsBase is deprecated in v28.4.
5151
Bridge: ctr.NetworkSettings.Bridge,
5252
SandboxID: ctr.NetworkSettings.SandboxID,
5353
SandboxKey: ctr.NetworkSettings.SandboxKey,
@@ -231,13 +231,13 @@ func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, err
231231

232232
// getDefaultNetworkSettings creates the deprecated structure that holds the information
233233
// about the bridge network for a container.
234-
func getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) containertypes.DefaultNetworkSettings {
234+
func getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) containertypes.DefaultNetworkSettings { //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
235235
nw, ok := networks[networktypes.NetworkBridge]
236236
if !ok || nw.EndpointSettings == nil {
237-
return containertypes.DefaultNetworkSettings{}
237+
return containertypes.DefaultNetworkSettings{} //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
238238
}
239239

240-
return containertypes.DefaultNetworkSettings{
240+
return containertypes.DefaultNetworkSettings{ //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
241241
EndpointID: nw.EndpointSettings.EndpointID,
242242
Gateway: nw.EndpointSettings.Gateway,
243243
GlobalIPv6Address: nw.EndpointSettings.GlobalIPv6Address,

docs/api/v1.50.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,8 @@ definitions:
16081608
Bridge:
16091609
description: |
16101610
Name of the default bridge interface when dockerd's --bridge flag is set.
1611+
1612+
Deprecated: This field is only set when the daemon is started with the --bridge flag specified.
16111613
type: "string"
16121614
example: "docker0"
16131615
SandboxID:

docs/api/v1.51.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,8 @@ definitions:
16081608
Bridge:
16091609
description: |
16101610
Name of the default bridge interface when dockerd's --bridge flag is set.
1611+
1612+
Deprecated: This field is only set when the daemon is started with the --bridge flag specified.
16111613
type: "string"
16121614
example: "docker0"
16131615
SandboxID:

docs/api/version-history.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ keywords: "API, Docker, rcli, REST, documentation"
2020
* `GET /images/json` now sets the value of `Containers` field for all images
2121
to the count of containers using the image.
2222
This field was previously always -1.
23+
* Deprecated: The field `NetworkSettings.Bridge` returned by `GET /containers/{id}/json`
24+
is deprecated and will be removed in the next API version.
2325

2426
## v1.50 API changes
2527

@@ -974,9 +976,10 @@ are not part of the underlying image's Config, and deprecated:
974976
* `GET /containers/(name)/json` now accepts a `size` parameter. Setting this parameter to '1' returns container size information in the `SizeRw` and `SizeRootFs` fields.
975977
* `GET /containers/(name)/json` now returns a `NetworkSettings.Networks` field,
976978
detailing network settings per network. This field deprecates the
977-
`NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
978-
`NetworkSettings.IPPre 6D38 fixLen`, and `NetworkSettings.MacAddress` fields, which
979-
are still returned for backward-compatibility, but will be removed in a future version.
979+
`NetworkSettings.EndpointID`, `NetworkSettings.Gateway`, `NetworkSettings.GlobalIPv6Address`,
980+
`NetworkSettings.GlobalIPv6PrefixLen` `NetworkSettings.IPAddress`, `NetworkSettings.IPPrefixLen`,
981+
`NetworkSettings.IPv6Gateway`, `NetworkSettings.MacAddress` fields, which are
982+
still returned for backward-compatibility, but will be removed in a future version.
980983
* `GET /exec/(id)/json` now returns a `NetworkSettings.Networks` field,
981984
detailing networksettings per network. This field deprecates the
982985
`NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,

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
@@ -1046,9 +1046,6 @@ func (s *DockerCLINetworkSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
10461046
err := json.Unmarshal(body, &inspectCurrent)
10471047
assert.NilError(c, err)
10481048
assert.Equal(c, len(inspectCurrent.NetworkSettings.Networks), 3)
1049-
1050-
bridge := inspectCurrent.NetworkSettings.Networks["bridge"]
1051-
assert.Equal(c, bridge.IPAddress, inspectCurrent.NetworkSettings.IPAddress)
10521049
}
10531050

10541051
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
})

0 commit comments

Comments
 (0)
0