mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
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 <albinker@gmail.com>
(cherry picked from commit b7c597ec35)
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
@@ -38,18 +38,44 @@ type NetworkSettingsBase struct {
|
||||
SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release.
|
||||
}
|
||||
|
||||
// DefaultNetworkSettings holds network information
|
||||
// during the 2 release deprecation period.
|
||||
// It will be removed in Docker 1.11.
|
||||
// DefaultNetworkSettings holds the networking state for the default bridge, if the container is connected to that
|
||||
// network.
|
||||
//
|
||||
// Deprecated: this struct is deprecated since Docker v1.11 and will be removed in v29. You should look for the default
|
||||
// network in NetworkSettings.Networks instead.
|
||||
type DefaultNetworkSettings struct {
|
||||
EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox
|
||||
Gateway string // Gateway holds the gateway address for the network
|
||||
GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address
|
||||
GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
|
||||
IPAddress string // IPAddress holds the IPv4 address for the network
|
||||
IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address
|
||||
IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6
|
||||
MacAddress string // MacAddress holds the MAC address for the network
|
||||
// EndpointID uniquely represents a service endpoint in a Sandbox
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
EndpointID string
|
||||
// Gateway holds the gateway address for the network
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
Gateway string
|
||||
// GlobalIPv6Address holds network's global IPv6 address
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
GlobalIPv6Address string
|
||||
// GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
GlobalIPv6PrefixLen int
|
||||
// IPAddress holds the IPv4 address for the network
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
IPAddress string
|
||||
// IPPrefixLen represents mask length of network's IPv4 address
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
IPPrefixLen int
|
||||
// IPv6Gateway holds gateway address specific for IPv6
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
IPv6Gateway string
|
||||
// MacAddress holds the MAC address for the network
|
||||
//
|
||||
// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
|
||||
MacAddress string
|
||||
}
|
||||
|
||||
// NetworkSettingsSummary provides a summary of container's networks
|
||||
|
||||
@@ -54,7 +54,7 @@ type NetworkSettingsBase = container.NetworkSettingsBase //nolint:staticcheck //
|
||||
// It will be removed in Docker 1.11.
|
||||
//
|
||||
// Deprecated: use [container.DefaultNetworkSettings].
|
||||
type DefaultNetworkSettings = container.DefaultNetworkSettings
|
||||
type DefaultNetworkSettings = container.DefaultNetworkSettings //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
|
||||
|
||||
// SummaryNetworkSettings provides a summary of container's networks
|
||||
// in /containers/json.
|
||||
|
||||
@@ -231,13 +231,13 @@ func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, err
|
||||
|
||||
// getDefaultNetworkSettings creates the deprecated structure that holds the information
|
||||
// about the bridge network for a container.
|
||||
func getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) containertypes.DefaultNetworkSettings {
|
||||
func getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) containertypes.DefaultNetworkSettings { //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
|
||||
nw, ok := networks[networktypes.NetworkBridge]
|
||||
if !ok || nw.EndpointSettings == nil {
|
||||
return containertypes.DefaultNetworkSettings{}
|
||||
return containertypes.DefaultNetworkSettings{} //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
|
||||
}
|
||||
|
||||
return containertypes.DefaultNetworkSettings{
|
||||
return containertypes.DefaultNetworkSettings{ //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
|
||||
EndpointID: nw.EndpointSettings.EndpointID,
|
||||
Gateway: nw.EndpointSettings.Gateway,
|
||||
GlobalIPv6Address: nw.EndpointSettings.GlobalIPv6Address,
|
||||
|
||||
@@ -976,9 +976,10 @@ are not part of the underlying image's Config, and deprecated:
|
||||
* `GET /containers/(name)/json` now accepts a `size` parameter. Setting this parameter to '1' returns container size information in the `SizeRw` and `SizeRootFs` fields.
|
||||
* `GET /containers/(name)/json` now returns a `NetworkSettings.Networks` field,
|
||||
detailing network settings per network. This field deprecates the
|
||||
`NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
|
||||
`NetworkSettings.IPPrefixLen`, and `NetworkSettings.MacAddress` fields, which
|
||||
are still returned for backward-compatibility, but will be removed in a future version.
|
||||
`NetworkSettings.EndpointID`, `NetworkSettings.Gateway`, `NetworkSettings.GlobalIPv6Address`,
|
||||
`NetworkSettings.GlobalIPv6PrefixLen` `NetworkSettings.IPAddress`, `NetworkSettings.IPPrefixLen`,
|
||||
`NetworkSettings.IPv6Gateway`, `NetworkSettings.MacAddress` fields, which are
|
||||
still returned for backward-compatibility, but will be removed in a future version.
|
||||
* `GET /exec/(id)/json` now returns a `NetworkSettings.Networks` field,
|
||||
detailing networksettings per network. This field deprecates the
|
||||
`NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
|
||||
|
||||
@@ -103,7 +103,6 @@ func (s *DockerAPISuite) TestInspectAPIBridgeNetworkSettings121(c *testing.T) {
|
||||
assert.NilError(c, err)
|
||||
|
||||
settings := inspectJSON.NetworkSettings
|
||||
assert.Assert(c, settings.IPAddress != "")
|
||||
assert.Assert(c, settings.Networks["bridge"] != nil)
|
||||
assert.Equal(c, settings.IPAddress, settings.Networks["bridge"].IPAddress)
|
||||
assert.Assert(c, settings.Networks["bridge"].IPAddress != "")
|
||||
}
|
||||
|
||||
@@ -1046,9 +1046,6 @@ func (s *DockerCLINetworkSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
|
||||
err := json.Unmarshal(body, &inspectCurrent)
|
||||
assert.NilError(c, err)
|
||||
assert.Equal(c, len(inspectCurrent.NetworkSettings.Networks), 3)
|
||||
|
||||
bridge := inspectCurrent.NetworkSettings.Networks["bridge"]
|
||||
assert.Equal(c, bridge.IPAddress, inspectCurrent.NetworkSettings.IPAddress)
|
||||
}
|
||||
|
||||
func connectContainerToNetworks(t *testing.T, d *daemon.Daemon, cName string, nws []string) {
|
||||
|
||||
@@ -97,9 +97,10 @@ ff02::2 ip6-allrouters
|
||||
stdout := runCmd(ctrId, []string{"cat", "/etc/hosts"}, 0)
|
||||
// Append the container's own addresses/name to the expected hosts file content.
|
||||
inspect := container.Inspect(ctx, t, c, ctrId)
|
||||
exp := tc.expEtcHosts + inspect.NetworkSettings.IPAddress + "\t" + inspect.Config.Hostname + "\n"
|
||||
bridgeEp := inspect.NetworkSettings.Networks["bridge"]
|
||||
exp := tc.expEtcHosts + bridgeEp.IPAddress + "\t" + inspect.Config.Hostname + "\n"
|
||||
if tc.expIPv6Enabled {
|
||||
exp += inspect.NetworkSettings.GlobalIPv6Address + "\t" + inspect.Config.Hostname + "\n"
|
||||
exp += bridgeEp.GlobalIPv6Address + "\t" + inspect.Config.Hostname + "\n"
|
||||
}
|
||||
assert.Check(t, is.Equal(stdout, exp))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user