mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #38486 from thaJeztah/dont_use_deprecated_envclient
Remove use of deprecated client.NewEnvClient()
This commit is contained in:
commit
55b5b8de79
26 changed files with 90 additions and 90 deletions
|
@ -16,7 +16,7 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ For example, to list running containers (the equivalent of "docker ps"):
|
|||
)
|
||||
|
||||
func main() {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"gotest.tools/skip"
|
||||
)
|
||||
|
||||
func TestNewEnvClient(t *testing.T) {
|
||||
func TestNewClientWithOpsFromEnv(t *testing.T) {
|
||||
skip.If(t, runtime.GOOS == "windows")
|
||||
|
||||
testcases := []struct {
|
||||
|
@ -86,7 +86,7 @@ func TestNewEnvClient(t *testing.T) {
|
|||
defer env.PatchAll(t, nil)()
|
||||
for _, c := range testcases {
|
||||
env.PatchAll(t, c.envs)
|
||||
apiclient, err := NewEnvClient()
|
||||
apiclient, err := NewClientWithOpts(FromEnv)
|
||||
if c.expectedError != "" {
|
||||
assert.Check(t, is.Error(err, c.expectedError), c.doc)
|
||||
} else {
|
||||
|
@ -167,7 +167,7 @@ func TestParseHostURL(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestNewEnvClientSetsDefaultVersion(t *testing.T) {
|
||||
func TestNewClientWithOpsFromEnvSetsDefaultVersion(t *testing.T) {
|
||||
defer env.PatchAll(t, map[string]string{
|
||||
"DOCKER_HOST": "",
|
||||
"DOCKER_API_VERSION": "",
|
||||
|
@ -175,7 +175,7 @@ func TestNewEnvClientSetsDefaultVersion(t *testing.T) {
|
|||
"DOCKER_CERT_PATH": "",
|
||||
})()
|
||||
|
||||
client, err := NewEnvClient()
|
||||
client, err := NewClientWithOpts(FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ func TestNewEnvClientSetsDefaultVersion(t *testing.T) {
|
|||
|
||||
expected := "1.22"
|
||||
os.Setenv("DOCKER_API_VERSION", expected)
|
||||
client, err = NewEnvClient()
|
||||
client, err = NewClientWithOpts(FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ func TestNewEnvClientSetsDefaultVersion(t *testing.T) {
|
|||
func TestNegotiateAPIVersionEmpty(t *testing.T) {
|
||||
defer env.PatchAll(t, map[string]string{"DOCKER_API_VERSION": ""})()
|
||||
|
||||
client, err := NewEnvClient()
|
||||
client, err := NewClientWithOpts(FromEnv)
|
||||
assert.NilError(t, err)
|
||||
|
||||
ping := types.Ping{
|
||||
|
@ -219,7 +219,7 @@ func TestNegotiateAPIVersionEmpty(t *testing.T) {
|
|||
// TestNegotiateAPIVersion asserts that client.Client can
|
||||
// negotiate a compatible APIVersion with the server
|
||||
func TestNegotiateAPIVersion(t *testing.T) {
|
||||
client, err := NewEnvClient()
|
||||
client, err := NewClientWithOpts(FromEnv)
|
||||
assert.NilError(t, err)
|
||||
|
||||
expected := "1.21"
|
||||
|
@ -251,7 +251,7 @@ func TestNegotiateAPVersionOverride(t *testing.T) {
|
|||
expected := "9.99"
|
||||
defer env.PatchAll(t, map[string]string{"DOCKER_API_VERSION": expected})()
|
||||
|
||||
client, err := NewEnvClient()
|
||||
client, err := NewClientWithOpts(FromEnv)
|
||||
assert.NilError(t, err)
|
||||
|
||||
ping := types.Ping{
|
||||
|
|
|
@ -153,7 +153,7 @@ func ExampleClient_ContainerLogs_withTimeout() {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
client, _ := NewEnvClient()
|
||||
client, _ := NewClientWithOpts(FromEnv)
|
||||
reader, err := client.ContainerLogs(ctx, "container_id", types.ContainerLogsOptions{})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
@ -65,7 +65,7 @@ func ExampleClient_ContainerWait_withTimeout() {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
client, _ := NewEnvClient()
|
||||
client, _ := NewClientWithOpts(FromEnv)
|
||||
_, errC := client.ContainerWait(ctx, "container_id", "")
|
||||
if err := <-errC; err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
@ -122,7 +122,7 @@ func ExampleClient_ServiceLogs_withTimeout() {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
client, _ := NewEnvClient()
|
||||
client, _ := NewClientWithOpts(FromEnv)
|
||||
reader, err := client.ServiceLogs(ctx, "service_id", types.ContainerLogsOptions{})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
@ -29,7 +29,7 @@ func dryTestChunkExecutor() testChunkExecutor {
|
|||
// service via bind-mounted API socket so as to execute the test chunk
|
||||
func privilegedTestChunkExecutor(autoRemove bool) testChunkExecutor {
|
||||
return func(image string, tests []string) (int64, string, error) {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
return 0, "", err
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func xmain() (int, error) {
|
|||
if *randSeed == int64(0) {
|
||||
*randSeed = time.Now().UnixNano()
|
||||
}
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ func (s *DockerSuite) TestPostContainersAttach(c *check.C) {
|
|||
expectTimeout(conn, br, "stdout")
|
||||
|
||||
// Test the client API
|
||||
client, err := client.NewEnvClient()
|
||||
client, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer client.Close()
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) {
|
|||
name := "getall"
|
||||
dockerCmd(c, "run", "--name", name, "busybox", "true")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -62,7 +62,7 @@ func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) {
|
|||
startCount := getContainerCount(c)
|
||||
dockerCmd(c, "run", "busybox", "true")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -111,7 +111,7 @@ func (s *DockerSuite) TestContainerAPIPsOmitFields(c *check.C) {
|
|||
port := 80
|
||||
runSleepingContainer(c, "--name", name, "--expose", strconv.Itoa(port))
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -143,7 +143,7 @@ func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) {
|
|||
name := "exportcontainer"
|
||||
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -170,7 +170,7 @@ func (s *DockerSuite) TestContainerAPIGetChanges(c *check.C) {
|
|||
name := "changescontainer"
|
||||
dockerCmd(c, "run", "--name", name, "busybox", "rm", "/etc/passwd")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -200,7 +200,7 @@ func (s *DockerSuite) TestGetContainerStats(c *check.C) {
|
|||
|
||||
bc := make(chan b, 1)
|
||||
go func() {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -234,7 +234,7 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
|
|||
buf := &ChannelBuffer{C: make(chan []byte, 1)}
|
||||
defer buf.Close()
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -305,7 +305,7 @@ func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) {
|
|||
|
||||
bc := make(chan b, 1)
|
||||
go func() {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -347,7 +347,7 @@ func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) {
|
|||
bc := make(chan b, 1)
|
||||
|
||||
go func() {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -384,7 +384,7 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
|
|||
// We expect an immediate response, but if it's not immediate, the test would hang, so put it in a goroutine
|
||||
// below we'll check this on a timeout.
|
||||
go func() {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -412,7 +412,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *check.C) {
|
|||
out := cli.DockerCmd(c, "run", "-d", "busybox", "sleep", "30").Combined()
|
||||
ContainerID := strings.TrimSpace(out)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -438,7 +438,7 @@ func (s *DockerSuite) TestContainerAPITop(c *check.C) {
|
|||
id := strings.TrimSpace(string(out))
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -461,7 +461,7 @@ func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) {
|
|||
id := strings.TrimSpace(string(out))
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -490,7 +490,7 @@ func (s *DockerSuite) TestContainerAPICommit(c *check.C) {
|
|||
cName := "testapicommit"
|
||||
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -512,7 +512,7 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *check.C) {
|
|||
cName := "testapicommitwithconfig"
|
||||
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -559,7 +559,7 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *check.C) {
|
|||
},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -573,7 +573,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *check.C) {
|
|||
Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -586,7 +586,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *check.C) {
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -610,7 +610,7 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *check.C) {
|
|||
},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -632,7 +632,7 @@ func (s *DockerSuite) TestContainerAPICreateWithHostName(c *check.C) {
|
|||
Domainname: domainName,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -668,7 +668,7 @@ func UtilCreateNetworkMode(c *check.C, networkMode containertypes.NetworkMode) {
|
|||
NetworkMode: networkMode,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -695,7 +695,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *check.C) {
|
|||
},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -943,7 +943,7 @@ func (s *DockerSuite) TestContainerAPIRename(c *check.C) {
|
|||
containerID := strings.TrimSpace(out)
|
||||
newName := "TestContainerAPIRenameNew"
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -958,7 +958,7 @@ func (s *DockerSuite) TestContainerAPIKill(c *check.C) {
|
|||
name := "test-api-kill"
|
||||
runSleepingContainer(c, "-i", "--name", name)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -972,7 +972,7 @@ func (s *DockerSuite) TestContainerAPIKill(c *check.C) {
|
|||
func (s *DockerSuite) TestContainerAPIRestart(c *check.C) {
|
||||
name := "test-api-restart"
|
||||
runSleepingContainer(c, "-di", "--name", name)
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -989,7 +989,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) {
|
|||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1007,7 +1007,7 @@ func (s *DockerSuite) TestContainerAPIStart(c *check.C) {
|
|||
OpenStdin: true,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ func (s *DockerSuite) TestContainerAPIStop(c *check.C) {
|
|||
runSleepingContainer(c, "-i", "--name", name)
|
||||
timeout := 30 * time.Second
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1053,7 +1053,7 @@ func (s *DockerSuite) TestContainerAPIWait(c *check.C) {
|
|||
}
|
||||
dockerCmd(c, "run", "--name", name, "busybox", sleepCmd, "2")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1171,7 +1171,7 @@ func (s *DockerSuite) TestContainerAPIDelete(c *check.C) {
|
|||
|
||||
dockerCmd(c, "stop", id)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1180,7 +1180,7 @@ func (s *DockerSuite) TestContainerAPIDelete(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1197,7 +1197,7 @@ func (s *DockerSuite) TestContainerAPIDeleteForce(c *check.C) {
|
|||
Force: true,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1225,7 +1225,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) {
|
|||
RemoveLinks: true,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1242,7 +1242,7 @@ func (s *DockerSuite) TestContainerAPIDeleteConflict(c *check.C) {
|
|||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1274,7 +1274,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
|
|||
RemoveVolumes: true,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1312,7 +1312,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *check.C) {
|
|||
containerID := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(containerID), checker.IsNil)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1329,7 +1329,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *c
|
|||
Cmd: []string{"hello", "world"},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1356,7 +1356,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *check.C) {
|
|||
Cmd: []string{"echo", "hello", "world"},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1397,7 +1397,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che
|
|||
CapDrop: []string{"SETGID"},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1453,7 +1453,7 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C)
|
|||
// Not supported on Windows
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1492,7 +1492,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *check.C) {
|
|||
ShmSize: -1,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1509,7 +1509,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check.
|
|||
Cmd: []string{"mount"},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1536,7 +1536,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) {
|
|||
Cmd: []string{"mount"},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1567,7 +1567,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) {
|
|||
ShmSize: 1073741824,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1593,7 +1593,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
|
|||
Image: "busybox",
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1623,7 +1623,7 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che
|
|||
OomScoreAdj: 1001,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1646,7 +1646,7 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che
|
|||
|
||||
// test case for #22210 where an empty container name caused panic.
|
||||
func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *check.C) {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1666,7 +1666,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) {
|
|||
NetworkDisabled: true,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -1978,7 +1978,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
|
|||
}...)
|
||||
|
||||
}
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -2013,7 +2013,7 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *check.C) {
|
|||
{Type: "bind", Source: tmpDir, Target: destPath},
|
||||
},
|
||||
}
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -2264,7 +2264,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) {
|
|||
},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ func (s *DockerSuite) TestExecAPICreateContainerPaused(c *check.C) {
|
|||
|
||||
dockerCmd(c, "pause", name)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -155,7 +155,7 @@ func (s *DockerSuite) TestExecAPIStartWithDetach(c *check.C) {
|
|||
AttachStderr: true,
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
func (s *DockerSuite) TestAPIImagesFilter(c *check.C) {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -88,7 +88,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestAPIImagesDelete(c *check.C) {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -112,7 +112,7 @@ func (s *DockerSuite) TestAPIImagesDelete(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestInspectAPIImageResponse(c *check.C) {
|
||||
dockerCmd(c, "tag", "busybox:latest", "busybox:mytag")
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ func (s *DockerSuite) TestLogsAPIWithStdout(c *check.C) {
|
|||
func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *check.C) {
|
||||
name := "logs_test"
|
||||
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -102,7 +102,7 @@ func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
until := daemonTime(c).Add(untilDur)
|
||||
|
||||
client, err := client.NewEnvClient()
|
||||
client, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ func (s *DockerSuite) TestLogsAPIUntil(c *check.C) {
|
|||
name := "logsuntil"
|
||||
dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; sleep 1; done")
|
||||
|
||||
client, err := client.NewEnvClient()
|
||||
client, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ func (s *DockerSuite) TestLogsAPIUntilDefaultValue(c *check.C) {
|
|||
name := "logsuntildefaultval"
|
||||
dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; done")
|
||||
|
||||
client, err := client.NewEnvClient()
|
||||
client, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ func jsonBlobHasGTE121NetworkStats(blob map[string]interface{}) bool {
|
|||
|
||||
func (s *DockerSuite) TestAPIStatsContainerNotFound(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -458,7 +458,7 @@ func (s *DockerSuite) TestEventsResize(c *check.C) {
|
|||
cID := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cID), checker.IsNil)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ func (s *DockerSuite) TestExecInspectID(c *check.C) {
|
|||
}
|
||||
|
||||
// But we should still be able to query the execID
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ func (s *DockerSuite) TestPluginLogDriverInfoList(c *check.C) {
|
|||
|
||||
dockerCmd(c, "plugin", "install", pluginName)
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -3893,7 +3893,7 @@ func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *check.C) {
|
|||
cid, _ := dockerCmd(c, "run", "-d", "--name=parent", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true")
|
||||
dockerCmd(c, "run", "--name=child", "--volumes-from=parent", "busybox", "true")
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -1568,7 +1568,7 @@ func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) {
|
|||
out, _ := dockerCmd(c, "run", "--cpus", "0.5", "--name", "test", "busybox", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2))
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000")
|
||||
|
||||
clt, err := client.NewEnvClient()
|
||||
clt, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
inspect, err := clt.ContainerInspect(context.Background(), "test")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
|
|
@ -309,7 +309,7 @@ func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) {
|
|||
out, _ = dockerCmd(c, "exec", "top", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2))
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000")
|
||||
|
||||
clt, err := client.NewEnvClient()
|
||||
clt, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
inspect, err := clt.ContainerInspect(context.Background(), "top")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
|
|
@ -600,7 +600,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *check.C
|
|||
err := os.MkdirAll("/tmp/data", 0755)
|
||||
c.Assert(err, checker.IsNil)
|
||||
// Mounts is available in API
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ func daemonTime(c *check.C) time.Time {
|
|||
if testEnv.IsLocalDaemon() {
|
||||
return time.Now()
|
||||
}
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
c.Assert(err, check.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
|
@ -373,7 +373,7 @@ func minimalBaseImage() string {
|
|||
}
|
||||
|
||||
func getGoroutineNumber() (int, error) {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ func MinimumAPIVersion(version string) func() bool {
|
|||
}
|
||||
|
||||
func OnlyDefaultNetworks() bool {
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
cli, err := client.NewEnvClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
assert.NilError(t, err)
|
||||
defer cli.Close()
|
||||
|
||||
|
|
|
@ -559,7 +559,7 @@ func (d *Daemon) LoadBusybox(t assert.TestingT) {
|
|||
if ht, ok := t.(test.HelperT); ok {
|
||||
ht.Helper()
|
||||
}
|
||||
clientHost, err := client.NewEnvClient()
|
||||
clientHost, err := client.NewClientWithOpts(client.FromEnv)
|
||||
assert.NilError(t, err, "failed to create client")
|
||||
defer clientHost.Close()
|
||||
|
||||
|
|
Loading…
Reference in a new issue