diff --git a/daemon/inspect.go b/daemon/inspect.go index 306ac7cbbd..62c7896ac3 100644 --- a/daemon/inspect.go +++ b/daemon/inspect.go @@ -14,7 +14,6 @@ import ( containertypes "github.com/docker/docker/api/types/container" networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/versions" - "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/container" "github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/network" @@ -29,8 +28,6 @@ import ( // there is an error getting the data. func (daemon *Daemon) ContainerInspect(ctx context.Context, name string, size bool, version string) (interface{}, error) { switch { - case versions.Equal(version, "1.20"): - return daemon.containerInspect120(name) case versions.LessThan(version, "1.45"): ctr, err := daemon.ContainerInspectCurrent(ctx, name, size) if err != nil { @@ -115,35 +112,6 @@ func (daemon *Daemon) ContainerInspectCurrent(ctx context.Context, name string, }, nil } -// containerInspect120 serializes the master version of a container into a json type. -func (daemon *Daemon) containerInspect120(name string) (*v1p20.ContainerJSON, error) { - ctr, err := daemon.GetContainer(name) - if err != nil { - return nil, err - } - - ctr.Lock() - defer ctr.Unlock() - - base, err := daemon.getInspectData(&daemon.config().Config, ctr) - if err != nil { - return nil, err - } - - return &v1p20.ContainerJSON{ - ContainerJSONBase: base, - Mounts: ctr.GetMountPoints(), - Config: &v1p20.ContainerConfig{ - Config: ctr.Config, - MacAddress: ctr.Config.MacAddress, //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44. - NetworkDisabled: ctr.Config.NetworkDisabled, - ExposedPorts: ctr.Config.ExposedPorts, - VolumeDriver: ctr.HostConfig.VolumeDriver, - }, - NetworkSettings: daemon.getBackwardsCompatibleNetworkSettings(ctr.NetworkSettings), - }, nil -} - func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *container.Container) (*types.ContainerJSONBase, error) { // make a copy to play with hostConfig := *container.HostConfig @@ -281,25 +249,6 @@ func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, err }, nil } -func (daemon *Daemon) getBackwardsCompatibleNetworkSettings(settings *network.Settings) *v1p20.NetworkSettings { - result := &v1p20.NetworkSettings{ - NetworkSettingsBase: types.NetworkSettingsBase{ - Bridge: settings.Bridge, - SandboxID: settings.SandboxID, - SandboxKey: settings.SandboxKey, - HairpinMode: settings.HairpinMode, - LinkLocalIPv6Address: settings.LinkLocalIPv6Address, - LinkLocalIPv6PrefixLen: settings.LinkLocalIPv6PrefixLen, - Ports: settings.Ports, - SecondaryIPAddresses: settings.SecondaryIPAddresses, - SecondaryIPv6Addresses: settings.SecondaryIPv6Addresses, - }, - DefaultNetworkSettings: daemon.getDefaultNetworkSettings(settings.Networks), - } - - return result -} - // getDefaultNetworkSettings creates the deprecated structure that holds the information // about the bridge network for a container. func (daemon *Daemon) getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) types.DefaultNetworkSettings { diff --git a/integration-cli/docker_api_inspect_test.go b/integration-cli/docker_api_inspect_test.go index b89986acdd..dde0c244e2 100644 --- a/integration-cli/docker_api_inspect_test.go +++ b/integration-cli/docker_api_inspect_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/testutil" @@ -31,12 +30,13 @@ func (s *DockerAPISuite) TestInspectAPIContainerResponse(c *testing.T) { var cases []acase if testEnv.DaemonInfo.OSType == "windows" { + // Windows only supports 1.25 or later cases = []acase{ {"v1.25", append(keysBase, "Mounts")}, } } else { cases = []acase{ - {"v1.20", append(keysBase, "Mounts")}, + {"v1.24", append(keysBase, "Mounts")}, } } @@ -58,28 +58,6 @@ func (s *DockerAPISuite) TestInspectAPIContainerResponse(c *testing.T) { } } -func (s *DockerAPISuite) TestInspectAPIContainerVolumeDriverLegacy(c *testing.T) { - // No legacy implications for Windows - testRequires(c, DaemonIsLinux) - out := cli.DockerCmd(c, "run", "-d", "busybox", "true").Stdout() - cleanedContainerID := strings.TrimSpace(out) - - cases := []string{"v1.20"} - for _, version := range cases { - body := getInspectBody(c, version, cleanedContainerID) - - var inspectJSON map[string]interface{} - err := json.Unmarshal(body, &inspectJSON) - assert.NilError(c, err, "Unable to unmarshal body for version %s", version) - - config, ok := inspectJSON["Config"] - assert.Assert(c, ok, "Unable to find 'Config'") - cfg := config.(map[string]interface{}) - _, ok = cfg["VolumeDriver"] - assert.Assert(c, ok, "API version %s expected to include VolumeDriver in 'Config'", version) - } -} - func (s *DockerAPISuite) TestInspectAPIContainerVolumeDriver(c *testing.T) { out := cli.DockerCmd(c, "run", "-d", "--volume-driver", "local", "busybox", "true").Stdout() cleanedContainerID := strings.TrimSpace(out) @@ -117,47 +95,6 @@ func (s *DockerAPISuite) TestInspectAPIImageResponse(c *testing.T) { assert.Check(c, is.Contains(imageJSON.RepoTags, "busybox:mytag")) } -// #17131, #17139, #17173 -func (s *DockerAPISuite) TestInspectAPIEmptyFieldsInConfigPre121(c *testing.T) { - // Not relevant on Windows - testRequires(c, DaemonIsLinux) - out := cli.DockerCmd(c, "run", "-d", "busybox", "true").Stdout() - cleanedContainerID := strings.TrimSpace(out) - - cases := []string{"v1.20"} - for _, version := range cases { - body := getInspectBody(c, version, cleanedContainerID) - - var inspectJSON map[string]interface{} - err := json.Unmarshal(body, &inspectJSON) - assert.NilError(c, err, "Unable to unmarshal body for version %s", version) - config, ok := inspectJSON["Config"] - assert.Assert(c, ok, "Unable to find 'Config'") - cfg := config.(map[string]interface{}) - for _, f := range []string{"MacAddress", "NetworkDisabled", "ExposedPorts"} { - _, ok := cfg[f] - assert.Check(c, ok, "API version %s expected to include %s in 'Config'", version, f) - } - } -} - -func (s *DockerAPISuite) TestInspectAPIBridgeNetworkSettings120(c *testing.T) { - // Not relevant on Windows, and besides it doesn't have any bridge network settings - testRequires(c, DaemonIsLinux) - out := cli.DockerCmd(c, "run", "-d", "busybox", "top").Stdout() - containerID := strings.TrimSpace(out) - cli.WaitRun(c, containerID) - - body := getInspectBody(c, "v1.20", containerID) - - var inspectJSON v1p20.ContainerJSON - err := json.Unmarshal(body, &inspectJSON) - assert.NilError(c, err) - - settings := inspectJSON.NetworkSettings - assert.Assert(c, len(settings.IPAddress) != 0) -} - // Inspect for API v1.21 and up; see // // - https://github.com/moby/moby/issues/17131 diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index e4d3d3fe0a..24a241ec3a 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/libnetwork/driverapi" @@ -1015,22 +1014,14 @@ func (s *DockerCLINetworkSuite) TestInspectAPIMultipleNetworks(c *testing.T) { cli.DockerCmd(c, "network", "connect", "mybridge1", id) cli.DockerCmd(c, "network", "connect", "mybridge2", id) - body := getInspectBody(c, "v1.20", id) - var inspect120 v1p20.ContainerJSON - err := json.Unmarshal(body, &inspect120) - assert.NilError(c, err) - - versionedIP := inspect120.NetworkSettings.IPAddress - // Current API version (API v1.21 and up) - body = getInspectBody(c, "", id) + body := getInspectBody(c, "", id) var inspectCurrent types.ContainerJSON - err = json.Unmarshal(body, &inspectCurrent) + 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, versionedIP) assert.Equal(c, bridge.IPAddress, inspectCurrent.NetworkSettings.IPAddress) }