mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
dc0c2340b8
integration-cli/docker_cli_pull_test.go:55:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_exec_test.go:46:64: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_service_health_test.go:86:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_images_test.go:128:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_node_test.go:79:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_health_test.go:51:57: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_health_test.go:159:73: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_swarm_unix_test.go:60:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_inspect_test.go:30:33: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_build_test.go:429:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_attach_unix_test.go:19:78: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_build_test.go:470:70: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_history_test.go:29:64: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_links_test.go:93:86: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:33:61: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_links_test.go:145:78: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:114:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_attach_test.go:226:153: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_by_digest_test.go:239:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_create_test.go:135:49: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:143:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:181:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_inspect_test.go:72:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:98:77: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:144:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_rmi_test.go:63:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:199:79: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_rmi_test.go:69:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:300:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_prune_unix_test.go:35:25: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_events_unix_test.go:393:60: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_events_unix_test.go:441:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_ps_test.go:33:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_ps_test.go:559:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_events_test.go:117:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:547:74: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_api_containers_test.go:1054:84: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:1076:87: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:1232:72: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_api_containers_test.go:1801:21: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_network_unix_test.go:58:95: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_network_unix_test.go:750:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_network_unix_test.go:765:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_swarm_test.go:617:100: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_swarm_test.go:892:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_daemon_test.go:119:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_daemon_test.go:981:68: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_daemon_test.go:1951:87: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_run_test.go:83:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_run_test.go:357:72: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_build_test.go:89:83: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:114:83: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:183:80: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:290:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:314:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:331:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:366:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:403:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:648:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:708:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:938:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1018:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1097:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1182:62: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1244:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1524:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1546:80: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1716:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1730:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2162:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2270:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2288:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3206:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3392:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3433:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3678:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3732:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3759:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3802:61: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3898:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4107:9: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4791:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4821:73: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4854:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:5341:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:5593:81: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:2145:11: empty-lines: extra empty line at the start of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
179 lines
5.8 KiB
Go
179 lines
5.8 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types/versions/v1p20"
|
|
"github.com/docker/docker/client"
|
|
"gotest.tools/v3/assert"
|
|
is "gotest.tools/v3/assert/cmp"
|
|
)
|
|
|
|
func (s *DockerAPISuite) TestInspectAPIContainerResponse(c *testing.T) {
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
|
keysBase := []string{"Id", "State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings",
|
|
"ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "MountLabel", "ProcessLabel", "GraphDriver"}
|
|
|
|
type acase struct {
|
|
version string
|
|
keys []string
|
|
}
|
|
|
|
var cases []acase
|
|
|
|
if testEnv.OSType == "windows" {
|
|
cases = []acase{
|
|
{"v1.25", append(keysBase, "Mounts")},
|
|
}
|
|
} else {
|
|
cases = []acase{
|
|
{"v1.20", append(keysBase, "Mounts")},
|
|
{"v1.19", append(keysBase, "Volumes", "VolumesRW")},
|
|
}
|
|
}
|
|
|
|
for _, cs := range cases {
|
|
body := getInspectBody(c, cs.version, cleanedContainerID)
|
|
|
|
var inspectJSON map[string]interface{}
|
|
err := json.Unmarshal(body, &inspectJSON)
|
|
assert.NilError(c, err, "Unable to unmarshal body for version %s", cs.version)
|
|
|
|
for _, key := range cs.keys {
|
|
_, ok := inspectJSON[key]
|
|
assert.Check(c, ok, "%s does not exist in response for version %s", key, cs.version)
|
|
}
|
|
|
|
// Issue #6830: type not properly converted to JSON/back
|
|
_, ok := inspectJSON["Path"].(bool)
|
|
assert.Assert(c, !ok, "Path of `true` should not be converted to boolean `true` via JSON marshalling")
|
|
}
|
|
}
|
|
|
|
func (s *DockerAPISuite) TestInspectAPIContainerVolumeDriverLegacy(c *testing.T) {
|
|
// No legacy implications for Windows
|
|
testRequires(c, DaemonIsLinux)
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
|
|
|
cases := []string{"v1.19", "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, _ := dockerCmd(c, "run", "-d", "--volume-driver", "local", "busybox", "true")
|
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
|
|
|
body := getInspectBody(c, "v1.25", cleanedContainerID)
|
|
|
|
var inspectJSON map[string]interface{}
|
|
err := json.Unmarshal(body, &inspectJSON)
|
|
assert.NilError(c, err, "Unable to unmarshal body for version 1.25")
|
|
|
|
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 1.25 expected to not include VolumeDriver in 'Config'")
|
|
|
|
config, ok = inspectJSON["HostConfig"]
|
|
assert.Assert(c, ok, "Unable to find 'HostConfig'")
|
|
cfg = config.(map[string]interface{})
|
|
_, ok = cfg["VolumeDriver"]
|
|
assert.Assert(c, ok, "API version 1.25 expected to include VolumeDriver in 'HostConfig'")
|
|
}
|
|
|
|
func (s *DockerAPISuite) TestInspectAPIImageResponse(c *testing.T) {
|
|
dockerCmd(c, "tag", "busybox:latest", "busybox:mytag")
|
|
cli, err := client.NewClientWithOpts(client.FromEnv)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
|
|
imageJSON, _, err := cli.ImageInspectWithRaw(context.Background(), "busybox")
|
|
assert.NilError(c, err)
|
|
|
|
assert.Check(c, len(imageJSON.RepoTags) == 2)
|
|
assert.Check(c, is.Contains(imageJSON.RepoTags, "busybox:latest"))
|
|
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, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
|
|
|
cases := []string{"v1.19", "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, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
|
containerID := strings.TrimSpace(out)
|
|
waitRun(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)
|
|
}
|
|
|
|
func (s *DockerAPISuite) TestInspectAPIBridgeNetworkSettings121(c *testing.T) {
|
|
// Windows doesn't have any bridge network settings
|
|
testRequires(c, DaemonIsLinux)
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
|
containerID := strings.TrimSpace(out)
|
|
waitRun(containerID)
|
|
|
|
body := getInspectBody(c, "v1.21", containerID)
|
|
|
|
var inspectJSON types.ContainerJSON
|
|
err := json.Unmarshal(body, &inspectJSON)
|
|
assert.NilError(c, err)
|
|
|
|
settings := inspectJSON.NetworkSettings
|
|
assert.Assert(c, len(settings.IPAddress) != 0)
|
|
assert.Assert(c, settings.Networks["bridge"] != nil)
|
|
assert.Equal(c, settings.IPAddress, settings.Networks["bridge"].IPAddress)
|
|
}
|