Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -566,7 +566,7 @@ func (d *Daemon) WaitRun(contID string) error {
|
| 566 | 566 |
|
| 567 | 567 |
// Info returns the info struct for this daemon |
| 568 | 568 |
func (d *Daemon) Info(t require.TestingT) types.Info {
|
| 569 |
- apiclient, err := request.NewClientForHost(d.Sock()) |
|
| 569 |
+ apiclient, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 570 | 570 |
require.NoError(t, err) |
| 571 | 571 |
info, err := apiclient.Info(context.Background()) |
| 572 | 572 |
require.NoError(t, err) |
| ... | ... |
@@ -1372,7 +1372,8 @@ func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) {
|
| 1372 | 1372 |
Image: "busybox", |
| 1373 | 1373 |
} |
| 1374 | 1374 |
|
| 1375 |
- cli, err := request.NewEnvClientWithVersion("v1.18")
|
|
| 1375 |
+ cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.18"))
|
|
| 1376 |
+ c.Assert(err, checker.IsNil) |
|
| 1376 | 1377 |
|
| 1377 | 1378 |
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "")
|
| 1378 | 1379 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -179,7 +179,7 @@ func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) {
|
| 179 | 179 |
Labels map[string]string |
| 180 | 180 |
} |
| 181 | 181 |
|
| 182 |
- cli, err = request.NewEnvClientWithVersion("v1.24")
|
|
| 182 |
+ cli, err = client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.24"))
|
|
| 183 | 183 |
c.Assert(err, checker.IsNil) |
| 184 | 184 |
defer cli.Close() |
| 185 | 185 |
|
| ... | ... |
@@ -5,8 +5,8 @@ package main |
| 5 | 5 |
import ( |
| 6 | 6 |
"encoding/json" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/client" |
|
| 8 | 9 |
"github.com/docker/docker/integration-cli/checker" |
| 9 |
- "github.com/docker/docker/integration-cli/request" |
|
| 10 | 10 |
"github.com/go-check/check" |
| 11 | 11 |
"golang.org/x/net/context" |
| 12 | 12 |
) |
| ... | ... |
@@ -18,7 +18,7 @@ func (s *DockerSuite) TestInspectAPICpusetInConfigPre120(c *check.C) {
|
| 18 | 18 |
|
| 19 | 19 |
name := "cpusetinconfig-pre120" |
| 20 | 20 |
dockerCmd(c, "run", "--name", name, "--cpuset-cpus", "0", "busybox", "true") |
| 21 |
- cli, err := request.NewEnvClientWithVersion("v1.19")
|
|
| 21 |
+ cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.19"))
|
|
| 22 | 22 |
c.Assert(err, checker.IsNil) |
| 23 | 23 |
defer cli.Close() |
| 24 | 24 |
_, body, err := cli.ContainerInspectWithRaw(context.Background(), name, false) |
| ... | ... |
@@ -372,7 +372,7 @@ func waitInspectWithArgs(name, expr, expected string, timeout time.Duration, arg |
| 372 | 372 |
} |
| 373 | 373 |
|
| 374 | 374 |
func getInspectBody(c *check.C, version, id string) []byte {
|
| 375 |
- cli, err := request.NewEnvClientWithVersion(version) |
|
| 375 |
+ cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(version)) |
|
| 376 | 376 |
c.Assert(err, check.IsNil) |
| 377 | 377 |
defer cli.Close() |
| 378 | 378 |
_, body, err := cli.ContainerInspectWithRaw(context.Background(), id, false) |
| ... | ... |
@@ -17,7 +17,6 @@ import ( |
| 17 | 17 |
"strings" |
| 18 | 18 |
"time" |
| 19 | 19 |
|
| 20 |
- "github.com/docker/docker/api" |
|
| 21 | 20 |
dclient "github.com/docker/docker/client" |
| 22 | 21 |
"github.com/docker/docker/opts" |
| 23 | 22 |
"github.com/docker/docker/pkg/ioutils" |
| ... | ... |
@@ -169,16 +168,7 @@ func NewHTTPClient(host string) (*http.Client, error) {
|
| 169 | 169 |
|
| 170 | 170 |
// NewClient returns a new Docker API client |
| 171 | 171 |
func NewClient() (dclient.APIClient, error) {
|
| 172 |
- return NewClientForHost(DaemonHost()) |
|
| 173 |
-} |
|
| 174 |
- |
|
| 175 |
-// NewClientForHost returns a Docker API client for the host |
|
| 176 |
-func NewClientForHost(host string) (dclient.APIClient, error) {
|
|
| 177 |
- httpClient, err := NewHTTPClient(host) |
|
| 178 |
- if err != nil {
|
|
| 179 |
- return nil, err |
|
| 180 |
- } |
|
| 181 |
- return dclient.NewClient(host, api.DefaultVersion, httpClient, nil) |
|
| 172 |
+ return dclient.NewClientWithOpts(dclient.WithHost(DaemonHost())) |
|
| 182 | 173 |
} |
| 183 | 174 |
|
| 184 | 175 |
// FIXME(vdemeester) httputil.ClientConn is deprecated, use http.Client instead (closer to actual client) |
| ... | ... |
@@ -323,35 +313,3 @@ func DaemonHost() string {
|
| 323 | 323 |
} |
| 324 | 324 |
return daemonURLStr |
| 325 | 325 |
} |
| 326 |
- |
|
| 327 |
-// NewEnvClientWithVersion returns a docker client with a specified version. |
|
| 328 |
-// See: github.com/docker/docker/client `NewEnvClient()` |
|
| 329 |
-func NewEnvClientWithVersion(version string) (*dclient.Client, error) {
|
|
| 330 |
- if version == "" {
|
|
| 331 |
- return nil, errors.New("version not specified")
|
|
| 332 |
- } |
|
| 333 |
- |
|
| 334 |
- var httpClient *http.Client |
|
| 335 |
- if os.Getenv("DOCKER_CERT_PATH") != "" {
|
|
| 336 |
- tlsConfig, err := getTLSConfig() |
|
| 337 |
- if err != nil {
|
|
| 338 |
- return nil, err |
|
| 339 |
- } |
|
| 340 |
- httpClient = &http.Client{
|
|
| 341 |
- Transport: &http.Transport{
|
|
| 342 |
- TLSClientConfig: tlsConfig, |
|
| 343 |
- }, |
|
| 344 |
- } |
|
| 345 |
- } |
|
| 346 |
- |
|
| 347 |
- host := os.Getenv("DOCKER_HOST")
|
|
| 348 |
- if host == "" {
|
|
| 349 |
- host = dclient.DefaultDockerHost |
|
| 350 |
- } |
|
| 351 |
- |
|
| 352 |
- cli, err := dclient.NewClient(host, version, httpClient, nil) |
|
| 353 |
- if err != nil {
|
|
| 354 |
- return cli, err |
|
| 355 |
- } |
|
| 356 |
- return cli, nil |
|
| 357 |
-} |
| ... | ... |
@@ -19,7 +19,6 @@ import ( |
| 19 | 19 |
func TestKillContainerInvalidSignal(t *testing.T) {
|
| 20 | 20 |
defer setupTest(t)() |
| 21 | 21 |
client := request.NewAPIClient(t) |
| 22 |
- t.Parallel() |
|
| 23 | 22 |
ctx := context.Background() |
| 24 | 23 |
c, err := client.ContainerCreate(ctx, |
| 25 | 24 |
&container.Config{
|
| ... | ... |
@@ -71,7 +70,6 @@ func TestKillContainer(t *testing.T) {
|
| 71 | 71 |
for _, tc := range testCases {
|
| 72 | 72 |
tc := tc |
| 73 | 73 |
t.Run(tc.doc, func(t *testing.T) {
|
| 74 |
- t.Parallel() |
|
| 75 | 74 |
ctx := context.Background() |
| 76 | 75 |
c, err := client.ContainerCreate(ctx, |
| 77 | 76 |
&container.Config{
|
| ... | ... |
@@ -117,7 +115,6 @@ func TestKillWithStopSignalAndRestartPolicies(t *testing.T) {
|
| 117 | 117 |
for _, tc := range testCases {
|
| 118 | 118 |
tc := tc |
| 119 | 119 |
t.Run(tc.doc, func(t *testing.T) {
|
| 120 |
- t.Parallel() |
|
| 121 | 120 |
ctx := context.Background() |
| 122 | 121 |
c, err := client.ContainerCreate(ctx, |
| 123 | 122 |
&container.Config{
|
| ... | ... |
@@ -145,7 +142,6 @@ func TestKillWithStopSignalAndRestartPolicies(t *testing.T) {
|
| 145 | 145 |
func TestKillStoppedContainer(t *testing.T) {
|
| 146 | 146 |
skip.If(t, testEnv.OSType != "linux") // Windows only supports 1.25 or later |
| 147 | 147 |
defer setupTest(t)() |
| 148 |
- t.Parallel() |
|
| 149 | 148 |
ctx := context.Background() |
| 150 | 149 |
client := request.NewAPIClient(t) |
| 151 | 150 |
c, err := client.ContainerCreate(ctx, |
| ... | ... |
@@ -165,7 +161,6 @@ func TestKillStoppedContainer(t *testing.T) {
|
| 165 | 165 |
func TestKillStoppedContainerAPIPre120(t *testing.T) {
|
| 166 | 166 |
skip.If(t, testEnv.OSType != "linux") // Windows only supports 1.25 or later |
| 167 | 167 |
defer setupTest(t)() |
| 168 |
- t.Parallel() |
|
| 169 | 168 |
ctx := context.Background() |
| 170 | 169 |
client := request.NewAPIClient(t, client.WithVersion("1.19"))
|
| 171 | 170 |
c, err := client.ContainerCreate(ctx, |
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"github.com/docker/docker/api/types/swarm" |
| 12 | 12 |
"github.com/docker/docker/client" |
| 13 | 13 |
"github.com/docker/docker/integration-cli/daemon" |
| 14 |
- "github.com/docker/docker/integration-cli/request" |
|
| 15 | 14 |
"github.com/gotestyourself/gotestyourself/poll" |
| 16 | 15 |
"github.com/stretchr/testify/require" |
| 17 | 16 |
"golang.org/x/net/context" |
| ... | ... |
@@ -24,7 +23,7 @@ func TestInspectNetwork(t *testing.T) {
|
| 24 | 24 |
defer setupTest(t)() |
| 25 | 25 |
d := newSwarm(t) |
| 26 | 26 |
defer d.Stop(t) |
| 27 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 27 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 28 | 28 |
require.NoError(t, err) |
| 29 | 29 |
|
| 30 | 30 |
overlayName := "overlay1" |
| ... | ... |
@@ -4,7 +4,7 @@ import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
swarmtypes "github.com/docker/docker/api/types/swarm" |
| 7 |
- "github.com/docker/docker/integration-cli/request" |
|
| 7 |
+ "github.com/docker/docker/client" |
|
| 8 | 8 |
"github.com/docker/docker/integration/util/swarm" |
| 9 | 9 |
"github.com/gotestyourself/gotestyourself/skip" |
| 10 | 10 |
"github.com/stretchr/testify/assert" |
| ... | ... |
@@ -18,7 +18,7 @@ func TestSecretInspect(t *testing.T) {
|
| 18 | 18 |
defer setupTest(t)() |
| 19 | 19 |
d := swarm.NewSwarm(t, testEnv) |
| 20 | 20 |
defer d.Stop(t) |
| 21 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 21 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 22 | 22 |
require.NoError(t, err) |
| 23 | 23 |
|
| 24 | 24 |
ctx := context.Background() |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"github.com/docker/docker/api/types/filters" |
| 11 | 11 |
swarmtypes "github.com/docker/docker/api/types/swarm" |
| 12 | 12 |
"github.com/docker/docker/client" |
| 13 |
- "github.com/docker/docker/integration-cli/request" |
|
| 14 | 13 |
"github.com/docker/docker/integration/util/swarm" |
| 15 | 14 |
"github.com/gotestyourself/gotestyourself/poll" |
| 16 | 15 |
"github.com/stretchr/testify/assert" |
| ... | ... |
@@ -22,7 +21,7 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
| 22 | 22 |
defer setupTest(t)() |
| 23 | 23 |
d := swarm.NewSwarm(t, testEnv) |
| 24 | 24 |
defer d.Stop(t) |
| 25 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 25 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 26 | 26 |
require.NoError(t, err) |
| 27 | 27 |
|
| 28 | 28 |
overlayName := "overlay1" |
| ... | ... |
@@ -88,7 +87,7 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
|
| 88 | 88 |
defer setupTest(t)() |
| 89 | 89 |
d := swarm.NewSwarm(t, testEnv) |
| 90 | 90 |
defer d.Stop(t) |
| 91 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 91 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 92 | 92 |
require.NoError(t, err) |
| 93 | 93 |
|
| 94 | 94 |
name := "foo" |
| ... | ... |
@@ -150,7 +149,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
| 150 | 150 |
defer setupTest(t)() |
| 151 | 151 |
d := swarm.NewSwarm(t, testEnv) |
| 152 | 152 |
defer d.Stop(t) |
| 153 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 153 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 154 | 154 |
require.NoError(t, err) |
| 155 | 155 |
|
| 156 | 156 |
ctx := context.Background() |
| ... | ... |
@@ -231,7 +230,7 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
| 231 | 231 |
defer setupTest(t)() |
| 232 | 232 |
d := swarm.NewSwarm(t, testEnv) |
| 233 | 233 |
defer d.Stop(t) |
| 234 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 234 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 235 | 235 |
require.NoError(t, err) |
| 236 | 236 |
|
| 237 | 237 |
ctx := context.Background() |
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/api/types/filters" |
| 10 | 10 |
swarmtypes "github.com/docker/docker/api/types/swarm" |
| 11 | 11 |
"github.com/docker/docker/client" |
| 12 |
- "github.com/docker/docker/integration-cli/request" |
|
| 13 | 12 |
"github.com/docker/docker/integration/util/swarm" |
| 14 | 13 |
"github.com/gotestyourself/gotestyourself/poll" |
| 15 | 14 |
"github.com/gotestyourself/gotestyourself/skip" |
| ... | ... |
@@ -23,7 +22,7 @@ func TestInspect(t *testing.T) {
|
| 23 | 23 |
defer setupTest(t)() |
| 24 | 24 |
d := swarm.NewSwarm(t, testEnv) |
| 25 | 25 |
defer d.Stop(t) |
| 26 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 26 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 27 | 27 |
require.NoError(t, err) |
| 28 | 28 |
|
| 29 | 29 |
var before = time.Now() |
| ... | ... |
@@ -7,7 +7,7 @@ import ( |
| 7 | 7 |
"github.com/docker/docker/api/types" |
| 8 | 8 |
"github.com/docker/docker/api/types/container" |
| 9 | 9 |
"github.com/docker/docker/api/types/network" |
| 10 |
- "github.com/docker/docker/integration-cli/request" |
|
| 10 |
+ "github.com/docker/docker/client" |
|
| 11 | 11 |
"github.com/docker/docker/integration/util/swarm" |
| 12 | 12 |
"github.com/stretchr/testify/assert" |
| 13 | 13 |
"github.com/stretchr/testify/require" |
| ... | ... |
@@ -17,7 +17,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
| 17 | 17 |
defer setupTest(t)() |
| 18 | 18 |
d := swarm.NewSwarm(t, testEnv) |
| 19 | 19 |
defer d.Stop(t) |
| 20 |
- client, err := request.NewClientForHost(d.Sock()) |
|
| 20 |
+ client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 21 | 21 |
require.NoError(t, err) |
| 22 | 22 |
ctx := context.Background() |
| 23 | 23 |
|
| ... | ... |
@@ -32,7 +32,7 @@ type PlatformDefaults struct {
|
| 32 | 32 |
|
| 33 | 33 |
// New creates a new Execution struct |
| 34 | 34 |
func New() (*Execution, error) {
|
| 35 |
- client, err := client.NewEnvClient() |
|
| 35 |
+ client, err := client.NewClientWithOpts(client.FromEnv) |
|
| 36 | 36 |
if err != nil {
|
| 37 | 37 |
return nil, errors.Wrapf(err, "failed to create client") |
| 38 | 38 |
} |