Browse code

client: deprecate NewClientWithOpts in favor of New

Use a more idiomatic name so that it can be used as `client.New()`.

We should look if we want `New()` to have different / updated defaults
i.e., enable `WithEnv` as default, and have an opt-out and have API-
version negotiation enabled by default (with an opt-out option).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/10/30 01:20:49
Showing 129 changed files
... ...
@@ -23,7 +23,7 @@ import (
23 23
 )
24 24
 
25 25
 func main() {
26
-	apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
26
+	apiClient, err := client.New(client.FromEnv, client.WithAPIVersionNegotiation())
27 27
 	if err != nil {
28 28
 		panic(err)
29 29
 	}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestCheckpointCreateError(t *testing.T) {
17
-	client, err := NewClientWithOpts(
17
+	client, err := New(
18 18
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
19 19
 	)
20 20
 	assert.NilError(t, err)
... ...
@@ -42,7 +42,7 @@ func TestCheckpointCreate(t *testing.T) {
42 42
 		expectedURL          = "/containers/container_id/checkpoints"
43 43
 	)
44 44
 
45
-	client, err := NewClientWithOpts(
45
+	client, err := New(
46 46
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
47 47
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
48 48
 				return nil, err
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestCheckpointDeleteError(t *testing.T) {
14
-	client, err := NewClientWithOpts(
14
+	client, err := New(
15 15
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
16 16
 	)
17 17
 	assert.NilError(t, err)
... ...
@@ -34,7 +34,7 @@ func TestCheckpointDeleteError(t *testing.T) {
34 34
 func TestCheckpointDelete(t *testing.T) {
35 35
 	const expectedURL = "/containers/container_id/checkpoints/checkpoint_id"
36 36
 
37
-	client, err := NewClientWithOpts(
37
+	client, err := New(
38 38
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
39 39
 			if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
40 40
 				return nil, err
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestCheckpointListError(t *testing.T) {
15
-	client, err := NewClientWithOpts(
15
+	client, err := New(
16 16
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
17 17
 	)
18 18
 	assert.NilError(t, err)
... ...
@@ -24,7 +24,7 @@ func TestCheckpointListError(t *testing.T) {
24 24
 func TestCheckpointList(t *testing.T) {
25 25
 	const expectedURL = "/containers/container_id/checkpoints"
26 26
 
27
-	client, err := NewClientWithOpts(
27
+	client, err := New(
28 28
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
29 29
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
30 30
 				return nil, err
... ...
@@ -42,7 +42,7 @@ func TestCheckpointList(t *testing.T) {
42 42
 }
43 43
 
44 44
 func TestCheckpointListContainerNotFound(t *testing.T) {
45
-	client, err := NewClientWithOpts(
45
+	client, err := New(
46 46
 		WithMockClient(errorMock(http.StatusNotFound, "Server error")),
47 47
 	)
48 48
 	assert.NilError(t, err)
... ...
@@ -6,7 +6,7 @@ https://docs.docker.com/reference/api/engine/
6 6
 
7 7
 # Usage
8 8
 
9
-You use the library by constructing a client object using [NewClientWithOpts]
9
+You use the library by constructing a client object using [New]
10 10
 and calling methods on it. The client can be configured from environment
11 11
 variables by passing the [FromEnv] option, and the [WithAPIVersionNegotiation]
12 12
 option to allow downgrading the API version used when connecting with an older
... ...
@@ -30,7 +30,7 @@ For example, to list running containers (the equivalent of "docker ps"):
30 30
 		// for configuration (DOCKER_HOST, DOCKER_API_VERSION), and does
31 31
 		// API-version negotiation to allow downgrading the API version
32 32
 		// when connecting with an older daemon version.
33
-		apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
33
+		apiClient, err := client.New(client.FromEnv, client.WithAPIVersionNegotiation())
34 34
 		if err != nil {
35 35
 			log.Fatal(err)
36 36
 		}
... ...
@@ -160,7 +160,14 @@ func CheckRedirect(_ *http.Request, via []*http.Request) error {
160 160
 	return ErrRedirect
161 161
 }
162 162
 
163
-// NewClientWithOpts initializes a new API client with a default HTTPClient, and
163
+// NewClientWithOpts initializes a new API client.
164
+//
165
+// Deprecated: use New. This function will be removed in the next release.
166
+func NewClientWithOpts(ops ...Opt) (*Client, error) {
167
+	return New(ops...)
168
+}
169
+
170
+// New initializes a new API client with a default HTTPClient, and
164 171
 // default API host and version. It also initializes the custom HTTP headers to
165 172
 // add to each request.
166 173
 //
... ...
@@ -170,11 +177,11 @@ func CheckRedirect(_ *http.Request, via []*http.Request) error {
170 170
 // itself with values from environment variables ([FromEnv]), and has automatic
171 171
 // API version negotiation enabled ([WithAPIVersionNegotiation]).
172 172
 //
173
-//	cli, err := client.NewClientWithOpts(
173
+//	cli, err := client.New(
174 174
 //		client.FromEnv,
175 175
 //		client.WithAPIVersionNegotiation(),
176 176
 //	)
177
-func NewClientWithOpts(ops ...Opt) (*Client, error) {
177
+func New(ops ...Opt) (*Client, error) {
178 178
 	hostURL, err := ParseHostURL(DefaultDockerHost)
179 179
 	if err != nil {
180 180
 		return nil, err
... ...
@@ -8,12 +8,12 @@ import (
8 8
 	"github.com/moby/moby/client"
9 9
 )
10 10
 
11
-func ExampleNewClientWithOpts() {
11
+func ExampleNew() {
12 12
 	// Create a new client that handles common environment variables
13 13
 	// for configuration (DOCKER_HOST, DOCKER_API_VERSION), and does
14 14
 	// API-version negotiation to allow downgrading the API version
15 15
 	// when connecting with an older daemon version.
16
-	apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
16
+	apiClient, err := client.New(client.FromEnv, client.WithAPIVersionNegotiation())
17 17
 	if err != nil {
18 18
 		log.Fatal(err)
19 19
 	}
... ...
@@ -92,7 +92,7 @@ func TestNewClientWithOpsFromEnv(t *testing.T) {
92 92
 			for key, value := range tc.envs {
93 93
 				t.Setenv(key, value)
94 94
 			}
95
-			client, err := NewClientWithOpts(FromEnv)
95
+			client, err := New(FromEnv)
96 96
 			if tc.expectedError != "" {
97 97
 				assert.Check(t, is.Error(err, tc.expectedError))
98 98
 			} else {
... ...
@@ -174,7 +174,7 @@ func TestGetAPIPath(t *testing.T) {
174 174
 
175 175
 	ctx := context.TODO()
176 176
 	for _, tc := range tests {
177
-		client, err := NewClientWithOpts(
177
+		client, err := New(
178 178
 			WithVersion(tc.version),
179 179
 			WithHost("tcp://localhost:2375"),
180 180
 		)
... ...
@@ -235,13 +235,13 @@ func TestNewClientWithOpsFromEnvSetsDefaultVersion(t *testing.T) {
235 235
 	t.Setenv("DOCKER_TLS_VERIFY", "")
236 236
 	t.Setenv("DOCKER_CERT_PATH", "")
237 237
 
238
-	client, err := NewClientWithOpts(FromEnv)
238
+	client, err := New(FromEnv)
239 239
 	assert.NilError(t, err)
240 240
 	assert.Check(t, is.Equal(client.ClientVersion(), MaxAPIVersion))
241 241
 
242 242
 	const expected = "1.50"
243 243
 	t.Setenv("DOCKER_API_VERSION", expected)
244
-	client, err = NewClientWithOpts(FromEnv)
244
+	client, err = New(FromEnv)
245 245
 	assert.NilError(t, err)
246 246
 	assert.Check(t, is.Equal(client.ClientVersion(), expected))
247 247
 }
... ...
@@ -256,7 +256,7 @@ func TestNegotiateAPIVersionEmpty(t *testing.T) {
256 256
 	// version before APIVersion was implemented
257 257
 	const expected = fallbackAPIVersion
258 258
 
259
-	client, err := NewClientWithOpts(FromEnv,
259
+	client, err := New(FromEnv,
260 260
 		WithAPIVersionNegotiation(),
261 261
 		WithMockClient(mockResponse(http.StatusOK, http.Header{"Api-Version": []string{expected}}, "OK")),
262 262
 	)
... ...
@@ -340,7 +340,7 @@ func TestNegotiateAPIVersion(t *testing.T) {
340 340
 				// doing this just to be explicit we are using the default.
341 341
 				opts = append(opts, WithVersion(tc.clientVersion))
342 342
 			}
343
-			client, err := NewClientWithOpts(opts...)
343
+			client, err := New(opts...)
344 344
 			assert.NilError(t, err)
345 345
 			_, err = client.Ping(t.Context(), PingOptions{
346 346
 				NegotiateAPIVersion: true,
... ...
@@ -361,7 +361,7 @@ func TestNegotiateAPIVersionOverride(t *testing.T) {
361 361
 	const expected = "9.99"
362 362
 	t.Setenv("DOCKER_API_VERSION", expected)
363 363
 
364
-	client, err := NewClientWithOpts(
364
+	client, err := New(
365 365
 		FromEnv,
366 366
 		WithMockClient(mockResponse(http.StatusOK, http.Header{"Api-Version": []string{"1.45"}}, "OK")),
367 367
 	)
... ...
@@ -379,7 +379,7 @@ func TestNegotiateAPIVersionOverride(t *testing.T) {
379 379
 func TestNegotiateAPIVersionConnectionFailure(t *testing.T) {
380 380
 	const expected = "9.99"
381 381
 
382
-	client, err := NewClientWithOpts(WithHost("tcp://no-such-host.invalid"))
382
+	client, err := New(WithHost("tcp://no-such-host.invalid"))
383 383
 	assert.NilError(t, err)
384 384
 	client.version = expected
385 385
 	_, err = client.Ping(t.Context(), PingOptions{
... ...
@@ -392,7 +392,7 @@ func TestNegotiateAPIVersionAutomatic(t *testing.T) {
392 392
 	var pingVersion string
393 393
 
394 394
 	ctx := t.Context()
395
-	client, err := NewClientWithOpts(
395
+	client, err := New(
396 396
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
397 397
 			hdr := http.Header{"Api-Version": []string{pingVersion}}
398 398
 			return mockResponse(http.StatusOK, hdr, "OK")(req)
... ...
@@ -421,7 +421,7 @@ func TestNegotiateAPIVersionAutomatic(t *testing.T) {
421 421
 // TestNegotiateAPIVersionWithEmptyVersion asserts that initializing a client
422 422
 // with an empty version string does still allow API-version negotiation
423 423
 func TestNegotiateAPIVersionWithEmptyVersion(t *testing.T) {
424
-	client, err := NewClientWithOpts(
424
+	client, err := New(
425 425
 		WithVersion(""),
426 426
 		WithMockClient(mockResponse(http.StatusOK, http.Header{"Api-Version": []string{"1.50"}}, "OK")),
427 427
 	)
... ...
@@ -438,7 +438,7 @@ func TestNegotiateAPIVersionWithEmptyVersion(t *testing.T) {
438 438
 // with a fixed version disables API-version negotiation
439 439
 func TestNegotiateAPIVersionWithFixedVersion(t *testing.T) {
440 440
 	const customVersion = "1.50"
441
-	client, err := NewClientWithOpts(
441
+	client, err := New(
442 442
 		WithVersion(customVersion),
443 443
 		WithMockClient(mockResponse(http.StatusOK, http.Header{"Api-Version": []string{"1.49"}}, "OK")),
444 444
 	)
... ...
@@ -515,12 +515,12 @@ func TestCustomAPIVersion(t *testing.T) {
515 515
 	}
516 516
 	for _, tc := range tests {
517 517
 		t.Run(tc.doc, func(t *testing.T) {
518
-			client, err := NewClientWithOpts(WithVersion(tc.version))
518
+			client, err := New(WithVersion(tc.version))
519 519
 			assert.NilError(t, err)
520 520
 			assert.Check(t, is.Equal(client.ClientVersion(), tc.expected))
521 521
 
522 522
 			t.Setenv(EnvOverrideAPIVersion, tc.expected)
523
-			client, err = NewClientWithOpts(WithVersionFromEnv())
523
+			client, err = New(WithVersionFromEnv())
524 524
 			assert.NilError(t, err)
525 525
 			assert.Check(t, is.Equal(client.ClientVersion(), tc.expected))
526 526
 		})
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestConfigCreateError(t *testing.T) {
15
-	client, err := NewClientWithOpts(
15
+	client, err := New(
16 16
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
17 17
 	)
18 18
 	assert.NilError(t, err)
... ...
@@ -23,7 +23,7 @@ func TestConfigCreateError(t *testing.T) {
23 23
 
24 24
 func TestConfigCreate(t *testing.T) {
25 25
 	const expectedURL = "/configs/create"
26
-	client, err := NewClientWithOpts(
26
+	client, err := New(
27 27
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
28 28
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
29 29
 				return nil, err
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestConfigInspectNotFound(t *testing.T) {
16
-	client, err := NewClientWithOpts(
16
+	client, err := New(
17 17
 		WithMockClient(errorMock(http.StatusNotFound, "Server error")),
18 18
 	)
19 19
 	assert.NilError(t, err)
... ...
@@ -23,7 +23,7 @@ func TestConfigInspectNotFound(t *testing.T) {
23 23
 }
24 24
 
25 25
 func TestConfigInspectWithEmptyID(t *testing.T) {
26
-	client, err := NewClientWithOpts(
26
+	client, err := New(
27 27
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
28 28
 			return nil, errors.New("should not make request")
29 29
 		}),
... ...
@@ -39,7 +39,7 @@ func TestConfigInspectWithEmptyID(t *testing.T) {
39 39
 }
40 40
 
41 41
 func TestConfigInspectError(t *testing.T) {
42
-	client, err := NewClientWithOpts(
42
+	client, err := New(
43 43
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
44 44
 	)
45 45
 	assert.NilError(t, err)
... ...
@@ -49,7 +49,7 @@ func TestConfigInspectError(t *testing.T) {
49 49
 }
50 50
 
51 51
 func TestConfigInspectConfigNotFound(t *testing.T) {
52
-	client, err := NewClientWithOpts(
52
+	client, err := New(
53 53
 		WithMockClient(errorMock(http.StatusNotFound, "Server error")),
54 54
 	)
55 55
 	assert.NilError(t, err)
... ...
@@ -60,7 +60,7 @@ func TestConfigInspectConfigNotFound(t *testing.T) {
60 60
 
61 61
 func TestConfigInspect(t *testing.T) {
62 62
 	const expectedURL = "/configs/config_id"
63
-	client, err := NewClientWithOpts(
63
+	client, err := New(
64 64
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
65 65
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
66 66
 				return nil, err
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestConfigListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(
16
+	client, err := New(
17 17
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
18 18
 	)
19 19
 	assert.NilError(t, err)
... ...
@@ -47,7 +47,7 @@ func TestConfigList(t *testing.T) {
47 47
 		},
48 48
 	}
49 49
 	for _, listCase := range listCases {
50
-		client, err := NewClientWithOpts(
50
+		client, err := New(
51 51
 			WithMockClient(func(req *http.Request) (*http.Response, error) {
52 52
 				if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
53 53
 					return nil, err
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestConfigRemoveError(t *testing.T) {
14
-	client, err := NewClientWithOpts(
14
+	client, err := New(
15 15
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
16 16
 	)
17 17
 	assert.NilError(t, err)
... ...
@@ -31,7 +31,7 @@ func TestConfigRemoveError(t *testing.T) {
31 31
 func TestConfigRemove(t *testing.T) {
32 32
 	const expectedURL = "/configs/config_id"
33 33
 
34
-	client, err := NewClientWithOpts(
34
+	client, err := New(
35 35
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
36 36
 			if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
37 37
 				return nil, err
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestConfigUpdateError(t *testing.T) {
14
-	client, err := NewClientWithOpts(
14
+	client, err := New(
15 15
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
16 16
 	)
17 17
 	assert.NilError(t, err)
... ...
@@ -31,7 +31,7 @@ func TestConfigUpdateError(t *testing.T) {
31 31
 func TestConfigUpdate(t *testing.T) {
32 32
 	const expectedURL = "/configs/config_id/update"
33 33
 
34
-	client, err := NewClientWithOpts(
34
+	client, err := New(
35 35
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
36 36
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
37 37
 				return nil, err
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestContainerCommitError(t *testing.T) {
16
-	client, err := NewClientWithOpts(
16
+	client, err := New(
17 17
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
18 18
 	)
19 19
 	assert.NilError(t, err)
... ...
@@ -42,7 +42,7 @@ func TestContainerCommit(t *testing.T) {
42 42
 	)
43 43
 	expectedChanges := []string{"change1", "change2"}
44 44
 
45
-	client, err := NewClientWithOpts(
45
+	client, err := New(
46 46
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
47 47
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
48 48
 				return nil, err
... ...
@@ -19,7 +19,7 @@ import (
19 19
 )
20 20
 
21 21
 func TestContainerStatPathError(t *testing.T) {
22
-	client, err := NewClientWithOpts(
22
+	client, err := New(
23 23
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
24 24
 	)
25 25
 	assert.NilError(t, err)
... ...
@@ -37,7 +37,7 @@ func TestContainerStatPathError(t *testing.T) {
37 37
 }
38 38
 
39 39
 func TestContainerStatPathNotFoundError(t *testing.T) {
40
-	client, err := NewClientWithOpts(
40
+	client, err := New(
41 41
 		WithMockClient(errorMock(http.StatusNotFound, "Not found")),
42 42
 	)
43 43
 	assert.NilError(t, err)
... ...
@@ -47,7 +47,7 @@ func TestContainerStatPathNotFoundError(t *testing.T) {
47 47
 }
48 48
 
49 49
 func TestContainerStatPathNoHeaderError(t *testing.T) {
50
-	client, err := NewClientWithOpts(
50
+	client, err := New(
51 51
 		WithMockClient(mockResponse(http.StatusOK, nil, "")),
52 52
 	)
53 53
 	assert.NilError(t, err)
... ...
@@ -61,7 +61,7 @@ func TestContainerStatPath(t *testing.T) {
61 61
 		expectedURL  = "/containers/container_id/archive"
62 62
 		expectedPath = "path/to/file"
63 63
 	)
64
-	client, err := NewClientWithOpts(
64
+	client, err := New(
65 65
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
66 66
 			if err := assertRequest(req, http.MethodHead, expectedURL); err != nil {
67 67
 				return nil, err
... ...
@@ -93,7 +93,7 @@ func TestContainerStatPath(t *testing.T) {
93 93
 }
94 94
 
95 95
 func TestCopyToContainerError(t *testing.T) {
96
-	client, err := NewClientWithOpts(
96
+	client, err := New(
97 97
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
98 98
 	)
99 99
 	assert.NilError(t, err)
... ...
@@ -120,7 +120,7 @@ func TestCopyToContainerError(t *testing.T) {
120 120
 }
121 121
 
122 122
 func TestCopyToContainerNotFoundError(t *testing.T) {
123
-	client, err := NewClientWithOpts(
123
+	client, err := New(
124 124
 		WithMockClient(errorMock(http.StatusNotFound, "Not found")),
125 125
 	)
126 126
 	assert.NilError(t, err)
... ...
@@ -135,7 +135,7 @@ func TestCopyToContainerNotFoundError(t *testing.T) {
135 135
 // TestCopyToContainerEmptyResponse verifies that no error is returned when a
136 136
 // "204 No Content" is returned by the API.
137 137
 func TestCopyToContainerEmptyResponse(t *testing.T) {
138
-	client, err := NewClientWithOpts(
138
+	client, err := New(
139 139
 		WithMockClient(errorMock(http.StatusNoContent, "No content")),
140 140
 	)
141 141
 	assert.NilError(t, err)
... ...
@@ -152,7 +152,7 @@ func TestCopyToContainer(t *testing.T) {
152 152
 		expectedURL  = "/containers/container_id/archive"
153 153
 		expectedPath = "path/to/file"
154 154
 	)
155
-	client, err := NewClientWithOpts(
155
+	client, err := New(
156 156
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
157 157
 			if err := assertRequest(req, http.MethodPut, expectedURL); err != nil {
158 158
 				return nil, err
... ...
@@ -192,7 +192,7 @@ func TestCopyToContainer(t *testing.T) {
192 192
 }
193 193
 
194 194
 func TestCopyFromContainerError(t *testing.T) {
195
-	client, err := NewClientWithOpts(
195
+	client, err := New(
196 196
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
197 197
 	)
198 198
 	assert.NilError(t, err)
... ...
@@ -210,7 +210,7 @@ func TestCopyFromContainerError(t *testing.T) {
210 210
 }
211 211
 
212 212
 func TestCopyFromContainerNotFoundError(t *testing.T) {
213
-	client, err := NewClientWithOpts(
213
+	client, err := New(
214 214
 		WithMockClient(errorMock(http.StatusNotFound, "Not found")),
215 215
 	)
216 216
 	assert.NilError(t, err)
... ...
@@ -222,7 +222,7 @@ func TestCopyFromContainerNotFoundError(t *testing.T) {
222 222
 // TestCopyFromContainerEmptyResponse verifies that no error is returned when a
223 223
 // "204 No Content" is returned by the API.
224 224
 func TestCopyFromContainerEmptyResponse(t *testing.T) {
225
-	client, err := NewClientWithOpts(
225
+	client, err := New(
226 226
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
227 227
 			content, err := json.Marshal(container.PathStat{
228 228
 				Name: "path/to/file",
... ...
@@ -245,7 +245,7 @@ func TestCopyFromContainerEmptyResponse(t *testing.T) {
245 245
 }
246 246
 
247 247
 func TestCopyFromContainerNoHeaderError(t *testing.T) {
248
-	client, err := NewClientWithOpts(
248
+	client, err := New(
249 249
 		WithMockClient(mockResponse(http.StatusOK, nil, "")),
250 250
 	)
251 251
 	assert.NilError(t, err)
... ...
@@ -259,7 +259,7 @@ func TestCopyFromContainer(t *testing.T) {
259 259
 		expectedURL  = "/containers/container_id/archive"
260 260
 		expectedPath = "path/to/file"
261 261
 	)
262
-	client, err := NewClientWithOpts(
262
+	client, err := New(
263 263
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
264 264
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
265 265
 				return nil, err
... ...
@@ -15,7 +15,7 @@ import (
15 15
 )
16 16
 
17 17
 func TestContainerCreateError(t *testing.T) {
18
-	client, err := NewClientWithOpts(
18
+	client, err := New(
19 19
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
20 20
 	)
21 21
 	assert.NilError(t, err)
... ...
@@ -29,7 +29,7 @@ func TestContainerCreateError(t *testing.T) {
29 29
 }
30 30
 
31 31
 func TestContainerCreateImageNotFound(t *testing.T) {
32
-	client, err := NewClientWithOpts(
32
+	client, err := New(
33 33
 		WithMockClient(errorMock(http.StatusNotFound, "No such image")),
34 34
 	)
35 35
 	assert.NilError(t, err)
... ...
@@ -40,7 +40,7 @@ func TestContainerCreateImageNotFound(t *testing.T) {
40 40
 
41 41
 func TestContainerCreateWithName(t *testing.T) {
42 42
 	const expectedURL = "/containers/create"
43
-	client, err := NewClientWithOpts(
43
+	client, err := New(
44 44
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
45 45
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
46 46
 				return nil, err
... ...
@@ -62,7 +62,7 @@ func TestContainerCreateWithName(t *testing.T) {
62 62
 }
63 63
 
64 64
 func TestContainerCreateAutoRemove(t *testing.T) {
65
-	client, err := NewClientWithOpts(
65
+	client, err := New(
66 66
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
67 67
 			var config container.CreateRequest
68 68
 			if err := json.NewDecoder(req.Body).Decode(&config); err != nil {
... ...
@@ -88,7 +88,7 @@ func TestContainerCreateAutoRemove(t *testing.T) {
88 88
 //
89 89
 // Regression test for https://github.com/docker/cli/issues/4890
90 90
 func TestContainerCreateConnectionError(t *testing.T) {
91
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
91
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
92 92
 	assert.NilError(t, err)
93 93
 
94 94
 	_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{Image: "test"}})
... ...
@@ -116,7 +116,7 @@ func TestContainerCreateCapabilities(t *testing.T) {
116 116
 		"CAP_CAPABILITY_D",
117 117
 	}
118 118
 
119
-	client, err := NewClientWithOpts(
119
+	client, err := New(
120 120
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
121 121
 			var config container.CreateRequest
122 122
 
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestContainerDiffError(t *testing.T) {
15
-	client, err := NewClientWithOpts(
15
+	client, err := New(
16 16
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
17 17
 	)
18 18
 	assert.NilError(t, err)
... ...
@@ -47,7 +47,7 @@ func TestContainerDiff(t *testing.T) {
47 47
 		},
48 48
 	}
49 49
 
50
-	client, err := NewClientWithOpts(
50
+	client, err := New(
51 51
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
52 52
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
53 53
 				return nil, err
... ...
@@ -15,7 +15,7 @@ import (
15 15
 )
16 16
 
17 17
 func TestExecCreateError(t *testing.T) {
18
-	client, err := NewClientWithOpts(
18
+	client, err := New(
19 19
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
20 20
 	)
21 21
 	assert.NilError(t, err)
... ...
@@ -37,7 +37,7 @@ func TestExecCreateError(t *testing.T) {
37 37
 //
38 38
 // Regression test for https://github.com/docker/cli/issues/4890
39 39
 func TestExecCreateConnectionError(t *testing.T) {
40
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
40
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
41 41
 	assert.NilError(t, err)
42 42
 
43 43
 	_, err = client.ExecCreate(context.Background(), "container_id", ExecCreateOptions{})
... ...
@@ -46,7 +46,7 @@ func TestExecCreateConnectionError(t *testing.T) {
46 46
 
47 47
 func TestExecCreate(t *testing.T) {
48 48
 	const expectedURL = "/containers/container_id/exec"
49
-	client, err := NewClientWithOpts(
49
+	client, err := New(
50 50
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
51 51
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
52 52
 				return nil, err
... ...
@@ -77,7 +77,7 @@ func TestExecCreate(t *testing.T) {
77 77
 }
78 78
 
79 79
 func TestExecStartError(t *testing.T) {
80
-	client, err := NewClientWithOpts(
80
+	client, err := New(
81 81
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
82 82
 	)
83 83
 	assert.NilError(t, err)
... ...
@@ -88,7 +88,7 @@ func TestExecStartError(t *testing.T) {
88 88
 
89 89
 func TestExecStart(t *testing.T) {
90 90
 	const expectedURL = "/exec/exec_id/start"
91
-	client, err := NewClientWithOpts(
91
+	client, err := New(
92 92
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
93 93
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
94 94
 				return nil, err
... ...
@@ -116,7 +116,7 @@ func TestExecStart(t *testing.T) {
116 116
 }
117 117
 
118 118
 func TestExecStartConsoleSize(t *testing.T) {
119
-	client, err := NewClientWithOpts(
119
+	client, err := New(
120 120
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
121 121
 			return nil, nil
122 122
 		}),
... ...
@@ -133,7 +133,7 @@ func TestExecStartConsoleSize(t *testing.T) {
133 133
 }
134 134
 
135 135
 func TestExecInspectError(t *testing.T) {
136
-	client, err := NewClientWithOpts(
136
+	client, err := New(
137 137
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
138 138
 	)
139 139
 	assert.NilError(t, err)
... ...
@@ -144,7 +144,7 @@ func TestExecInspectError(t *testing.T) {
144 144
 
145 145
 func TestExecInspect(t *testing.T) {
146 146
 	const expectedURL = "/exec/exec_id/json"
147
-	client, err := NewClientWithOpts(
147
+	client, err := New(
148 148
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
149 149
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
150 150
 				return nil, err
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestContainerExportError(t *testing.T) {
15
-	client, err := NewClientWithOpts(
15
+	client, err := New(
16 16
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
17 17
 	)
18 18
 	assert.NilError(t, err)
... ...
@@ -31,7 +31,7 @@ func TestContainerExportError(t *testing.T) {
31 31
 
32 32
 func TestContainerExport(t *testing.T) {
33 33
 	const expectedURL = "/containers/container_id/export"
34
-	client, err := NewClientWithOpts(
34
+	client, err := New(
35 35
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
36 36
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
37 37
 				return nil, err
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestContainerInspectError(t *testing.T) {
15
-	client, err := NewClientWithOpts(
15
+	client, err := New(
16 16
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
17 17
 	)
18 18
 	assert.NilError(t, err)
... ...
@@ -30,7 +30,7 @@ func TestContainerInspectError(t *testing.T) {
30 30
 }
31 31
 
32 32
 func TestContainerInspectContainerNotFound(t *testing.T) {
33
-	client, err := NewClientWithOpts(
33
+	client, err := New(
34 34
 		WithMockClient(errorMock(http.StatusNotFound, "Server error")),
35 35
 	)
36 36
 	assert.NilError(t, err)
... ...
@@ -40,7 +40,7 @@ func TestContainerInspectContainerNotFound(t *testing.T) {
40 40
 }
41 41
 
42 42
 func TestContainerInspectWithEmptyID(t *testing.T) {
43
-	client, err := NewClientWithOpts(
43
+	client, err := New(
44 44
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
45 45
 			return nil, errors.New("should not make request")
46 46
 		}),
... ...
@@ -58,7 +58,7 @@ func TestContainerInspectWithEmptyID(t *testing.T) {
58 58
 
59 59
 func TestContainerInspect(t *testing.T) {
60 60
 	const expectedURL = "/containers/container_id/json"
61
-	client, err := NewClientWithOpts(
61
+	client, err := New(
62 62
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
63 63
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
64 64
 				return nil, err
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestContainerKillError(t *testing.T) {
14
-	client, err := NewClientWithOpts(
14
+	client, err := New(
15 15
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
16 16
 	)
17 17
 	assert.NilError(t, err)
... ...
@@ -33,7 +33,7 @@ func TestContainerKillError(t *testing.T) {
33 33
 func TestContainerKill(t *testing.T) {
34 34
 	const expectedURL = "/containers/container_id/kill"
35 35
 	const expectedSignal = "SIG_SOMETHING"
36
-	client, err := NewClientWithOpts(
36
+	client, err := New(
37 37
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
38 38
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
39 39
 				return nil, err
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestContainerListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(
16
+	client, err := New(
17 17
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
18 18
 	)
19 19
 	assert.NilError(t, err)
... ...
@@ -27,7 +27,7 @@ func TestContainerList(t *testing.T) {
27 27
 		expectedURL     = "/containers/json"
28 28
 		expectedFilters = `{"before":{"container":true},"label":{"label1":true,"label2":true}}`
29 29
 	)
30
-	client, err := NewClientWithOpts(
30
+	client, err := New(
31 31
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
32 32
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
33 33
 				return nil, err
... ...
@@ -17,7 +17,7 @@ import (
17 17
 )
18 18
 
19 19
 func TestContainerLogsNotFoundError(t *testing.T) {
20
-	client, err := NewClientWithOpts(
20
+	client, err := New(
21 21
 		WithMockClient(errorMock(http.StatusNotFound, "Not found")),
22 22
 	)
23 23
 	assert.NilError(t, err)
... ...
@@ -35,7 +35,7 @@ func TestContainerLogsNotFoundError(t *testing.T) {
35 35
 }
36 36
 
37 37
 func TestContainerLogsError(t *testing.T) {
38
-	client, err := NewClientWithOpts(
38
+	client, err := New(
39 39
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
40 40
 	)
41 41
 	assert.NilError(t, err)
... ...
@@ -135,7 +135,7 @@ func TestContainerLogs(t *testing.T) {
135 135
 	}
136 136
 	for _, tc := range cases {
137 137
 		t.Run(tc.doc, func(t *testing.T) {
138
-			client, err := NewClientWithOpts(
138
+			client, err := New(
139 139
 				WithMockClient(func(req *http.Request) (*http.Response, error) {
140 140
 					if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
141 141
 						return nil, err
... ...
@@ -167,10 +167,13 @@ func TestContainerLogs(t *testing.T) {
167 167
 }
168 168
 
169 169
 func ExampleClient_ContainerLogs_withTimeout() {
170
+	client, err := New(FromEnv, WithAPIVersionNegotiation())
171
+	if err != nil {
172
+		log.Fatal(err)
173
+	}
174
+
170 175
 	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
171 176
 	defer cancel()
172
-
173
-	client, _ := NewClientWithOpts(FromEnv)
174 177
 	res, err := client.ContainerLogs(ctx, "container_id", ContainerLogsOptions{})
175 178
 	if err != nil {
176 179
 		log.Fatal(err)
... ...
@@ -10,7 +10,7 @@ import (
10 10
 )
11 11
 
12 12
 func TestContainerPauseError(t *testing.T) {
13
-	client, err := NewClientWithOpts(
13
+	client, err := New(
14 14
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
15 15
 	)
16 16
 	assert.NilError(t, err)
... ...
@@ -21,7 +21,7 @@ func TestContainerPauseError(t *testing.T) {
21 21
 
22 22
 func TestContainerPause(t *testing.T) {
23 23
 	const expectedURL = "/containers/container_id/pause"
24
-	client, err := NewClientWithOpts(
24
+	client, err := New(
25 25
 		WithMockClient(func(req *http.Request) (*http.Response, error) {
26 26
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
27 27
 				return nil, err
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestContainersPruneError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.ContainersPrune(context.Background(), ContainerPruneOptions{})
... ...
@@ -73,7 +73,7 @@ func TestContainersPrune(t *testing.T) {
73 73
 		},
74 74
 	}
75 75
 	for _, listCase := range listCases {
76
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
76
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
77 77
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
78 78
 				return nil, err
79 79
 			}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestContainerRemoveError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 	_, err = client.ContainerRemove(t.Context(), "container_id", ContainerRemoveOptions{})
17 17
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -26,7 +26,7 @@ func TestContainerRemoveError(t *testing.T) {
26 26
 }
27 27
 
28 28
 func TestContainerRemoveNotFoundError(t *testing.T) {
29
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "no such container: container_id")))
29
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "no such container: container_id")))
30 30
 	assert.NilError(t, err)
31 31
 	_, err = client.ContainerRemove(t.Context(), "container_id", ContainerRemoveOptions{})
32 32
 	assert.Check(t, is.ErrorContains(err, "no such container: container_id"))
... ...
@@ -35,7 +35,7 @@ func TestContainerRemoveNotFoundError(t *testing.T) {
35 35
 
36 36
 func TestContainerRemove(t *testing.T) {
37 37
 	const expectedURL = "/containers/container_id"
38
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
38
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
39 39
 		if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
40 40
 			return nil, err
41 41
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestContainerRenameError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 	_, err = client.ContainerRename(context.Background(), "nothing", ContainerRenameOptions{NewName: "newNothing"})
18 18
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -28,7 +28,7 @@ func TestContainerRenameError(t *testing.T) {
28 28
 
29 29
 func TestContainerRename(t *testing.T) {
30 30
 	const expectedURL = "/containers/container_id/rename"
31
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
31
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
32 32
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
33 33
 			return nil, err
34 34
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestContainerResizeError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 	_, err = client.ContainerResize(t.Context(), "container_id", ContainerResizeOptions{})
17 17
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -26,7 +26,7 @@ func TestContainerResizeError(t *testing.T) {
26 26
 }
27 27
 
28 28
 func TestExecResizeError(t *testing.T) {
29
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
29
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
30 30
 	assert.NilError(t, err)
31 31
 	_, err = client.ExecResize(t.Context(), "exec_id", ExecResizeOptions{})
32 32
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -67,7 +67,7 @@ func TestContainerResize(t *testing.T) {
67 67
 	}
68 68
 	for _, tc := range tests {
69 69
 		t.Run(tc.doc, func(t *testing.T) {
70
-			client, err := NewClientWithOpts(WithMockClient(resizeTransport(t, expectedURL, tc.expectedHeight, tc.expectedWidth)))
70
+			client, err := New(WithMockClient(resizeTransport(t, expectedURL, tc.expectedHeight, tc.expectedWidth)))
71 71
 			assert.NilError(t, err)
72 72
 			_, err = client.ContainerResize(t.Context(), "container_id", tc.opts)
73 73
 			assert.NilError(t, err)
... ...
@@ -109,7 +109,7 @@ func TestExecResize(t *testing.T) {
109 109
 	}
110 110
 	for _, tc := range tests {
111 111
 		t.Run(tc.doc, func(t *testing.T) {
112
-			client, err := NewClientWithOpts(WithMockClient(resizeTransport(t, expectedURL, tc.expectedHeight, tc.expectedWidth)))
112
+			client, err := New(WithMockClient(resizeTransport(t, expectedURL, tc.expectedHeight, tc.expectedWidth)))
113 113
 			assert.NilError(t, err)
114 114
 			_, err = client.ExecResize(t.Context(), "exec_id", tc.opts)
115 115
 			assert.NilError(t, err)
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestContainerRestartError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 	_, err = client.ContainerRestart(t.Context(), "nothing", ContainerRestartOptions{})
17 17
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -30,7 +30,7 @@ func TestContainerRestartError(t *testing.T) {
30 30
 //
31 31
 // Regression test for https://github.com/docker/cli/issues/4890
32 32
 func TestContainerRestartConnectionError(t *testing.T) {
33
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
33
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
34 34
 	assert.NilError(t, err)
35 35
 
36 36
 	_, err = client.ContainerRestart(t.Context(), "nothing", ContainerRestartOptions{})
... ...
@@ -39,7 +39,7 @@ func TestContainerRestartConnectionError(t *testing.T) {
39 39
 
40 40
 func TestContainerRestart(t *testing.T) {
41 41
 	const expectedURL = "/containers/container_id/restart"
42
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
42
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
43 43
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
44 44
 			return nil, err
45 45
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestContainerStartError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 	_, err = client.ContainerStart(t.Context(), "nothing", ContainerStartOptions{})
18 18
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -28,7 +28,7 @@ func TestContainerStartError(t *testing.T) {
28 28
 
29 29
 func TestContainerStart(t *testing.T) {
30 30
 	const expectedURL = "/containers/container_id/start"
31
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
31
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
32 32
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
33 33
 			return nil, err
34 34
 		}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestContainerStatsError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 	_, err = client.ContainerStats(t.Context(), "nothing", ContainerStatsOptions{})
20 20
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -43,7 +43,7 @@ func TestContainerStats(t *testing.T) {
43 43
 		},
44 44
 	}
45 45
 	for _, tc := range tests {
46
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
46
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
47 47
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
48 48
 				return nil, err
49 49
 			}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestContainerStopError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 	_, err = client.ContainerStop(t.Context(), "container_id", ContainerStopOptions{})
17 17
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -30,7 +30,7 @@ func TestContainerStopError(t *testing.T) {
30 30
 //
31 31
 // Regression test for https://github.com/docker/cli/issues/4890
32 32
 func TestContainerStopConnectionError(t *testing.T) {
33
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
33
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
34 34
 	assert.NilError(t, err)
35 35
 
36 36
 	_, err = client.ContainerStop(t.Context(), "container_id", ContainerStopOptions{})
... ...
@@ -39,7 +39,7 @@ func TestContainerStopConnectionError(t *testing.T) {
39 39
 
40 40
 func TestContainerStop(t *testing.T) {
41 41
 	const expectedURL = "/containers/container_id/stop"
42
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
42
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
43 43
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
44 44
 			return nil, err
45 45
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestContainerTopError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 	_, err = client.ContainerTop(context.Background(), "nothing", ContainerTopOptions{})
19 19
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -35,7 +35,7 @@ func TestContainerTop(t *testing.T) {
35 35
 	}
36 36
 	expectedTitles := []string{"title1", "title2"}
37 37
 
38
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
38
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
39 39
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
40 40
 			return nil, err
41 41
 		}
... ...
@@ -10,7 +10,7 @@ import (
10 10
 )
11 11
 
12 12
 func TestContainerUnpauseError(t *testing.T) {
13
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
13
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14 14
 	assert.NilError(t, err)
15 15
 	_, err = client.ContainerUnpause(t.Context(), "nothing", ContainerUnpauseOptions{})
16 16
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -26,7 +26,7 @@ func TestContainerUnpauseError(t *testing.T) {
26 26
 
27 27
 func TestContainerUnpause(t *testing.T) {
28 28
 	const expectedURL = "/containers/container_id/unpause"
29
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
29
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
30 30
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
31 31
 			return nil, err
32 32
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestContainerUpdateError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 	_, err = client.ContainerUpdate(context.Background(), "nothing", ContainerUpdateOptions{})
18 18
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -29,7 +29,7 @@ func TestContainerUpdateError(t *testing.T) {
29 29
 func TestContainerUpdate(t *testing.T) {
30 30
 	const expectedURL = "/containers/container_id/update"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -19,7 +19,7 @@ import (
19 19
 )
20 20
 
21 21
 func TestContainerWaitError(t *testing.T) {
22
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
22
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
23 23
 	assert.NilError(t, err)
24 24
 	wait := client.ContainerWait(t.Context(), "nothing", ContainerWaitOptions{})
25 25
 	select {
... ...
@@ -35,7 +35,7 @@ func TestContainerWaitError(t *testing.T) {
35 35
 //
36 36
 // Regression test for https://github.com/docker/cli/issues/4890
37 37
 func TestContainerWaitConnectionError(t *testing.T) {
38
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
38
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
39 39
 	assert.NilError(t, err)
40 40
 
41 41
 	wait := client.ContainerWait(t.Context(), "nothing", ContainerWaitOptions{})
... ...
@@ -49,7 +49,7 @@ func TestContainerWaitConnectionError(t *testing.T) {
49 49
 
50 50
 func TestContainerWait(t *testing.T) {
51 51
 	const expectedURL = "/containers/container_id/wait"
52
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
52
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
53 53
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
54 54
 			return nil, err
55 55
 		}
... ...
@@ -74,7 +74,7 @@ func TestContainerWaitProxyInterrupt(t *testing.T) {
74 74
 		expErr      = "copying response body from Docker: unexpected EOF"
75 75
 	)
76 76
 
77
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
77
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
78 78
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
79 79
 			return nil, err
80 80
 		}
... ...
@@ -94,7 +94,7 @@ func TestContainerWaitProxyInterrupt(t *testing.T) {
94 94
 func TestContainerWaitProxyInterruptLong(t *testing.T) {
95 95
 	const expectedURL = "/containers/container_id/wait"
96 96
 	msg := strings.Repeat("x", containerWaitErrorMsgLimit*5)
97
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
97
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
98 98
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
99 99
 			return nil, err
100 100
 		}
... ...
@@ -127,7 +127,7 @@ func TestContainerWaitErrorHandling(t *testing.T) {
127 127
 			ctx, cancel := context.WithCancel(t.Context())
128 128
 			defer cancel()
129 129
 
130
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
130
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
131 131
 				return &http.Response{
132 132
 					StatusCode: http.StatusOK,
133 133
 					Body:       io.NopCloser(test.rdr),
... ...
@@ -152,7 +152,7 @@ func ExampleClient_ContainerWait_withTimeout() {
152 152
 	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
153 153
 	defer cancel()
154 154
 
155
-	client, _ := NewClientWithOpts(FromEnv)
155
+	client, _ := New(FromEnv)
156 156
 	wait := client.ContainerWait(ctx, "container_id", ContainerWaitOptions{})
157 157
 	if err := <-wait.Error; err != nil {
158 158
 		log.Fatal(err)
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestDistributionInspectWithEmptyID(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
15
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
16 16
 		return nil, errors.New("should not make request")
17 17
 	}))
18 18
 	assert.NilError(t, err)
... ...
@@ -86,7 +86,7 @@ func TestTLSCloseWriter(t *testing.T) {
86 86
 	serverURL, err := url.Parse(ts.URL)
87 87
 	assert.NilError(t, err)
88 88
 
89
-	client, err := NewClientWithOpts(WithHost("tcp://"+serverURL.Host), WithHTTPClient(ts.Client()))
89
+	client, err := New(WithHost("tcp://"+serverURL.Host), WithHTTPClient(ts.Client()))
90 90
 	assert.NilError(t, err)
91 91
 
92 92
 	resp, err := client.postHijacked(context.Background(), "/asdf", url.Values{}, nil, map[string][]string{"Content-Type": {"text/plain"}})
... ...
@@ -16,7 +16,7 @@ import (
16 16
 )
17 17
 
18 18
 func TestImageBuildError(t *testing.T) {
19
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
19
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
20 20
 	assert.NilError(t, err)
21 21
 	_, err = client.ImageBuild(context.Background(), nil, ImageBuildOptions{})
22 22
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -154,7 +154,7 @@ func TestImageBuild(t *testing.T) {
154 154
 	}
155 155
 	const expectedURL = "/build"
156 156
 	for _, buildCase := range buildCases {
157
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
157
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
158 158
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
159 159
 				return nil, err
160 160
 			}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestImageCreateError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 	_, err = client.ImageCreate(context.Background(), "reference", ImageCreateOptions{})
20 20
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -29,7 +29,7 @@ func TestImageCreate(t *testing.T) {
29 29
 		expectedRegistryAuth = "eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOnsiYXV0aCI6ImRHOTBid289IiwiZW1haWwiOiJqb2huQGRvZS5jb20ifX0="
30 30
 	)
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestImageHistoryError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 	_, err = client.ImageHistory(context.Background(), "nothing")
19 19
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -25,7 +25,7 @@ func TestImageHistory(t *testing.T) {
25 25
 		historyResponse  = `[{"Comment":"","Created":0,"CreatedBy":"","Id":"image_id1","Size":0,"Tags":["tag1","tag2"]},{"Comment":"","Created":0,"CreatedBy":"","Id":"image_id2","Size":0,"Tags":["tag1","tag2"]}]`
26 26
 		expectedPlatform = `{"architecture":"arm64","os":"linux","variant":"v8"}`
27 27
 	)
28
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
28
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
29 29
 		assert.Check(t, assertRequest(req, http.MethodGet, expectedURL))
30 30
 		assert.Check(t, is.Equal(req.URL.Query().Get("platform"), expectedPlatform))
31 31
 		return mockResponse(http.StatusOK, nil, historyResponse)(req)
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestImageImportError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 	_, err = client.ImageImport(context.Background(), ImageImportSource{}, "image:tag", ImageImportOptions{})
20 20
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -66,7 +66,7 @@ func TestImageImport(t *testing.T) {
66 66
 	}
67 67
 	for _, tc := range tests {
68 68
 		t.Run(tc.doc, func(t *testing.T) {
69
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
69
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
70 70
 				assert.Check(t, assertRequest(req, http.MethodPost, expectedURL))
71 71
 				query := req.URL.Query()
72 72
 				assert.Check(t, is.DeepEqual(query, tc.expectedQueryParams))
... ...
@@ -15,7 +15,7 @@ import (
15 15
 )
16 16
 
17 17
 func TestImageInspectError(t *testing.T) {
18
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
19 19
 	assert.NilError(t, err)
20 20
 
21 21
 	_, err = client.ImageInspect(context.Background(), "nothing")
... ...
@@ -23,7 +23,7 @@ func TestImageInspectError(t *testing.T) {
23 23
 }
24 24
 
25 25
 func TestImageInspectImageNotFound(t *testing.T) {
26
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
26
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
27 27
 	assert.NilError(t, err)
28 28
 
29 29
 	_, err = client.ImageInspect(context.Background(), "unknown")
... ...
@@ -31,7 +31,7 @@ func TestImageInspectImageNotFound(t *testing.T) {
31 31
 }
32 32
 
33 33
 func TestImageInspectWithEmptyID(t *testing.T) {
34
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
34
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
35 35
 		return nil, errors.New("should not make request")
36 36
 	}))
37 37
 	assert.NilError(t, err)
... ...
@@ -42,7 +42,7 @@ func TestImageInspectWithEmptyID(t *testing.T) {
42 42
 func TestImageInspect(t *testing.T) {
43 43
 	const expectedURL = "/images/image_id/json"
44 44
 	expectedTags := []string{"tag1", "tag2"}
45
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
45
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
46 46
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
47 47
 			return nil, err
48 48
 		}
... ...
@@ -69,7 +69,7 @@ func TestImageInspectWithPlatform(t *testing.T) {
69 69
 	expectedPlatform, err := encodePlatform(requestedPlatform)
70 70
 	assert.NilError(t, err)
71 71
 
72
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
72
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
73 73
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
74 74
 			return nil, err
75 75
 		}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestImageListError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 
20 20
 	_, err = client.ImageList(context.Background(), ImageListOptions{})
... ...
@@ -26,7 +26,7 @@ func TestImageListError(t *testing.T) {
26 26
 //
27 27
 // Regression test for https://github.com/docker/cli/issues/4890
28 28
 func TestImageListConnectionError(t *testing.T) {
29
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
29
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
30 30
 	assert.NilError(t, err)
31 31
 
32 32
 	_, err = client.ImageList(context.Background(), ImageListOptions{})
... ...
@@ -73,7 +73,7 @@ func TestImageList(t *testing.T) {
73 73
 		},
74 74
 	}
75 75
 	for _, listCase := range listCases {
76
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
76
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
77 77
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
78 78
 				return nil, err
79 79
 			}
... ...
@@ -114,7 +114,7 @@ func TestImageListWithSharedSize(t *testing.T) {
114 114
 		t.Run(tc.name, func(t *testing.T) {
115 115
 			t.Parallel()
116 116
 			var query url.Values
117
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
117
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
118 118
 				query = req.URL.Query()
119 119
 				return mockResponse(http.StatusOK, nil, "[]")(req)
120 120
 			}), WithVersion(tc.version))
... ...
@@ -16,7 +16,7 @@ import (
16 16
 )
17 17
 
18 18
 func TestImageLoadError(t *testing.T) {
19
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
19
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
20 20
 	assert.NilError(t, err)
21 21
 
22 22
 	_, err = client.ImageLoad(context.Background(), nil, ImageLoadWithQuiet(true))
... ...
@@ -71,7 +71,7 @@ func TestImageLoad(t *testing.T) {
71 71
 	}
72 72
 	for _, tc := range tests {
73 73
 		t.Run(tc.doc, func(t *testing.T) {
74
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
74
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
75 75
 				assert.Check(t, assertRequest(req, http.MethodPost, expectedURL))
76 76
 				assert.Check(t, is.Equal(req.Header.Get("Content-Type"), expectedContentType))
77 77
 				assert.Check(t, is.DeepEqual(req.URL.Query(), tc.expectedQueryParams))
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestImagesPruneError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.ImagesPrune(context.Background(), ImagePruneOptions{})
... ...
@@ -63,7 +63,7 @@ func TestImagesPrune(t *testing.T) {
63 63
 		},
64 64
 	}
65 65
 	for _, listCase := range listCases {
66
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
66
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
67 67
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
68 68
 				return nil, err
69 69
 			}
... ...
@@ -18,7 +18,7 @@ import (
18 18
 )
19 19
 
20 20
 func TestImagePullReferenceParseError(t *testing.T) {
21
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
21
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
22 22
 		return nil, nil
23 23
 	}))
24 24
 	assert.NilError(t, err)
... ...
@@ -28,21 +28,21 @@ func TestImagePullReferenceParseError(t *testing.T) {
28 28
 }
29 29
 
30 30
 func TestImagePullAnyError(t *testing.T) {
31
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
31
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
32 32
 	assert.NilError(t, err)
33 33
 	_, err = client.ImagePull(context.Background(), "myimage", ImagePullOptions{})
34 34
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
35 35
 }
36 36
 
37 37
 func TestImagePullStatusUnauthorizedError(t *testing.T) {
38
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
38
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
39 39
 	assert.NilError(t, err)
40 40
 	_, err = client.ImagePull(context.Background(), "myimage", ImagePullOptions{})
41 41
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized))
42 42
 }
43 43
 
44 44
 func TestImagePullWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
45
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
45
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
46 46
 	assert.NilError(t, err)
47 47
 	_, err = client.ImagePull(context.Background(), "myimage", ImagePullOptions{
48 48
 		PrivilegeFunc: func(_ context.Context) (string, error) {
... ...
@@ -53,7 +53,7 @@ func TestImagePullWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
53 53
 }
54 54
 
55 55
 func TestImagePullWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T) {
56
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
56
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
57 57
 	assert.NilError(t, err)
58 58
 	_, err = client.ImagePull(context.Background(), "myimage", ImagePullOptions{
59 59
 		PrivilegeFunc: staticAuth("a-auth-header"),
... ...
@@ -65,7 +65,7 @@ func TestImagePullWithPrivilegedFuncNoError(t *testing.T) {
65 65
 	const expectedURL = "/images/create"
66 66
 	const invalidAuth = "NotValid"
67 67
 	const validAuth = "IAmValid"
68
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
68
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
69 69
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
70 70
 			return nil, err
71 71
 		}
... ...
@@ -161,7 +161,7 @@ func TestImagePullWithoutErrors(t *testing.T) {
161 161
 	}
162 162
 	for _, pullCase := range pullCases {
163 163
 		t.Run(pullCase.reference, func(t *testing.T) {
164
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
164
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
165 165
 				if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
166 166
 					return nil, err
167 167
 				}
... ...
@@ -15,7 +15,7 @@ import (
15 15
 )
16 16
 
17 17
 func TestImagePushReferenceError(t *testing.T) {
18
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
18
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
19 19
 		return nil, nil
20 20
 	}))
21 21
 	assert.NilError(t, err)
... ...
@@ -28,21 +28,21 @@ func TestImagePushReferenceError(t *testing.T) {
28 28
 }
29 29
 
30 30
 func TestImagePushAnyError(t *testing.T) {
31
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
31
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
32 32
 	assert.NilError(t, err)
33 33
 	_, err = client.ImagePush(context.Background(), "myimage", ImagePushOptions{})
34 34
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
35 35
 }
36 36
 
37 37
 func TestImagePushStatusUnauthorizedError(t *testing.T) {
38
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
38
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
39 39
 	assert.NilError(t, err)
40 40
 	_, err = client.ImagePush(context.Background(), "myimage", ImagePushOptions{})
41 41
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized))
42 42
 }
43 43
 
44 44
 func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
45
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
45
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
46 46
 	assert.NilError(t, err)
47 47
 	privilegeFunc := func(_ context.Context) (string, error) {
48 48
 		return "", errors.New("error requesting privilege")
... ...
@@ -54,7 +54,7 @@ func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
54 54
 }
55 55
 
56 56
 func TestImagePushWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T) {
57
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
57
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
58 58
 	assert.NilError(t, err)
59 59
 	privilegeFunc := func(_ context.Context) (string, error) {
60 60
 		return "a-auth-header", nil
... ...
@@ -69,7 +69,7 @@ func TestImagePushWithPrivilegedFuncNoError(t *testing.T) {
69 69
 	const expectedURL = "/images/docker.io/myname/myimage/push"
70 70
 	const invalidAuth = "NotValid"
71 71
 	const validAuth = "IAmValid"
72
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
72
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
73 73
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
74 74
 			return nil, err
75 75
 		}
... ...
@@ -161,7 +161,7 @@ func TestImagePushWithoutErrors(t *testing.T) {
161 161
 	}
162 162
 	for _, tc := range testCases {
163 163
 		t.Run(fmt.Sprintf("%s,all-tags=%t", tc.reference, tc.all), func(t *testing.T) {
164
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
164
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
165 165
 				expectedURL := fmt.Sprintf(expectedURLFormat, tc.expectedImage)
166 166
 				if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
167 167
 					return nil, err
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestImageRemoveError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 
20 20
 	_, err = client.ImageRemove(context.Background(), "image_id", ImageRemoveOptions{})
... ...
@@ -22,7 +22,7 @@ func TestImageRemoveError(t *testing.T) {
22 22
 }
23 23
 
24 24
 func TestImageRemoveImageNotFound(t *testing.T) {
25
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "no such image: unknown")))
25
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "no such image: unknown")))
26 26
 	assert.NilError(t, err)
27 27
 
28 28
 	_, err = client.ImageRemove(context.Background(), "unknown", ImageRemoveOptions{})
... ...
@@ -65,7 +65,7 @@ func TestImageRemove(t *testing.T) {
65 65
 		},
66 66
 	}
67 67
 	for _, removeCase := range removeCases {
68
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
68
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
69 69
 			if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
70 70
 				return nil, err
71 71
 			}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestImageSaveError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 	armv64 := ocispec.Platform{Architecture: "arm64", OS: "linux", Variant: "v8"}
20 20
 	_, err = client.ImageSave(context.Background(), []string{"nothing"}, ImageSaveWithPlatforms(armv64))
... ...
@@ -63,7 +63,7 @@ func TestImageSave(t *testing.T) {
63 63
 	}
64 64
 	for _, tc := range tests {
65 65
 		t.Run(tc.doc, func(t *testing.T) {
66
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
66
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
67 67
 				assert.Check(t, assertRequest(req, http.MethodGet, expectedURL))
68 68
 				assert.Check(t, is.DeepEqual(req.URL.Query(), tc.expectedQueryParams))
69 69
 				return mockResponse(http.StatusOK, nil, expectedOutput)(req)
... ...
@@ -14,21 +14,21 @@ import (
14 14
 )
15 15
 
16 16
 func TestImageSearchAnyError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 	_, err = client.ImageSearch(context.Background(), "some-image", ImageSearchOptions{})
20 20
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
21 21
 }
22 22
 
23 23
 func TestImageSearchStatusUnauthorizedError(t *testing.T) {
24
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
24
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
25 25
 	assert.NilError(t, err)
26 26
 	_, err = client.ImageSearch(context.Background(), "some-image", ImageSearchOptions{})
27 27
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized))
28 28
 }
29 29
 
30 30
 func TestImageSearchWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
31
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
31
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
32 32
 	assert.NilError(t, err)
33 33
 	privilegeFunc := func(_ context.Context) (string, error) {
34 34
 		return "", errors.New("Error requesting privilege")
... ...
@@ -40,7 +40,7 @@ func TestImageSearchWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
40 40
 }
41 41
 
42 42
 func TestImageSearchWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T) {
43
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
43
+	client, err := New(WithMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")))
44 44
 	assert.NilError(t, err)
45 45
 	privilegeFunc := func(_ context.Context) (string, error) {
46 46
 		return "a-auth-header", nil
... ...
@@ -53,7 +53,7 @@ func TestImageSearchWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.
53 53
 
54 54
 func TestImageSearchWithPrivilegedFuncNoError(t *testing.T) {
55 55
 	const expectedURL = "/images/search"
56
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
56
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
57 57
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
58 58
 			return nil, err
59 59
 		}
... ...
@@ -89,7 +89,7 @@ func TestImageSearchWithoutErrors(t *testing.T) {
89 89
 	const expectedURL = "/images/search"
90 90
 	const expectedFilters = `{"is-automated":{"true":true},"stars":{"3":true}}`
91 91
 
92
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
92
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
93 93
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
94 94
 			return nil, err
95 95
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestImageTagError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.ImageTag(context.Background(), ImageTagOptions{Source: "image_id", Target: "repo:tag"})
... ...
@@ -23,7 +23,7 @@ func TestImageTagError(t *testing.T) {
23 23
 // Note: this is not testing all the InvalidReference as it's the responsibility
24 24
 // of distribution/reference package.
25 25
 func TestImageTagInvalidReference(t *testing.T) {
26
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
26
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
27 27
 	assert.NilError(t, err)
28 28
 
29 29
 	_, err = client.ImageTag(context.Background(), ImageTagOptions{Source: "image_id", Target: "aa/asdf$$^/aa"})
... ...
@@ -34,7 +34,7 @@ func TestImageTagInvalidReference(t *testing.T) {
34 34
 func TestImageTagInvalidSourceImageName(t *testing.T) {
35 35
 	ctx := context.Background()
36 36
 
37
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "client should not have made an API call")))
37
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "client should not have made an API call")))
38 38
 	assert.NilError(t, err)
39 39
 
40 40
 	invalidRepos := []string{"fo$z$", "Foo@3cc", "Foo$3", "Foo*3", "Fo^3", "Foo!3", "F)xcz(", "fo%asd", "aa/asdf$$^/aa"}
... ...
@@ -86,7 +86,7 @@ func generateRandomAlphaOnlyString(n int) string {
86 86
 }
87 87
 
88 88
 func TestImageTagHexSource(t *testing.T) {
89
-	client, err := NewClientWithOpts(WithMockClient(mockResponse(http.StatusOK, nil, "OK")))
89
+	client, err := New(WithMockClient(mockResponse(http.StatusOK, nil, "OK")))
90 90
 	assert.NilError(t, err)
91 91
 
92 92
 	_, err = client.ImageTag(context.Background(), ImageTagOptions{Source: "0d409d33b27e47423b049f7f863faa08655a8c901749c2b25b93ca67d01a470d", Target: "repo:tag"})
... ...
@@ -150,7 +150,7 @@ func TestImageTag(t *testing.T) {
150 150
 		},
151 151
 	}
152 152
 	for _, tagCase := range tagCases {
153
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
153
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
154 154
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
155 155
 				return nil, err
156 156
 			}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestNetworkConnectError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 
20 20
 	_, err = client.NetworkConnect(context.Background(), "network_id", NetworkConnectOptions{
... ...
@@ -37,7 +37,7 @@ func TestNetworkConnectError(t *testing.T) {
37 37
 func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) {
38 38
 	const expectedURL = "/networks/network_id/connect"
39 39
 
40
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
40
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
41 41
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
42 42
 			return nil, err
43 43
 		}
... ...
@@ -68,7 +68,7 @@ func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) {
68 68
 func TestNetworkConnect(t *testing.T) {
69 69
 	const expectedURL = "/networks/network_id/connect"
70 70
 
71
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
71
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
72 72
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
73 73
 			return nil, err
74 74
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestNetworkCreateError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.NetworkCreate(context.Background(), "mynetwork", NetworkCreateOptions{})
... ...
@@ -24,7 +24,7 @@ func TestNetworkCreateError(t *testing.T) {
24 24
 //
25 25
 // Regression test for https://github.com/docker/cli/issues/4890
26 26
 func TestNetworkCreateConnectionError(t *testing.T) {
27
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
27
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
28 28
 	assert.NilError(t, err)
29 29
 
30 30
 	_, err = client.NetworkCreate(context.Background(), "mynetwork", NetworkCreateOptions{})
... ...
@@ -34,7 +34,7 @@ func TestNetworkCreateConnectionError(t *testing.T) {
34 34
 func TestNetworkCreate(t *testing.T) {
35 35
 	const expectedURL = "/networks/create"
36 36
 
37
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
37
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
38 38
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
39 39
 			return nil, err
40 40
 		}
... ...
@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 func TestNetworkDisconnectError(t *testing.T) {
17
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
18 18
 	assert.NilError(t, err)
19 19
 
20 20
 	_, err = client.NetworkDisconnect(context.Background(), "network_id", NetworkDisconnectOptions{
... ...
@@ -37,7 +37,7 @@ func TestNetworkDisconnectError(t *testing.T) {
37 37
 func TestNetworkDisconnect(t *testing.T) {
38 38
 	const expectedURL = "/networks/network_id/disconnect"
39 39
 
40
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
40
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
41 41
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
42 42
 			return nil, err
43 43
 		}
... ...
@@ -15,7 +15,7 @@ import (
15 15
 func TestNetworkInspect(t *testing.T) {
16 16
 	const expectedURL = "/networks/network_id"
17 17
 
18
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
18
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
19 19
 		if req.URL.Path == defaultAPIPath+"/networks/" {
20 20
 			return errorMock(http.StatusInternalServerError, "client should not make a request for empty IDs")(req)
21 21
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestNetworkListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.NetworkList(context.Background(), NetworkListOptions{})
... ...
@@ -54,7 +54,7 @@ func TestNetworkList(t *testing.T) {
54 54
 	}
55 55
 
56 56
 	for _, listCase := range listCases {
57
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
57
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
58 58
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
59 59
 				return nil, err
60 60
 			}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestNetworksPruneError(t *testing.T) {
15
-	client, err := NewClientWithOpts(
15
+	client, err := New(
16 16
 		WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
17 17
 	)
18 18
 	assert.NilError(t, err)
... ...
@@ -65,7 +65,7 @@ func TestNetworksPrune(t *testing.T) {
65 65
 		},
66 66
 	}
67 67
 	for _, listCase := range listCases {
68
-		client, err := NewClientWithOpts(
68
+		client, err := New(
69 69
 			WithMockClient(func(req *http.Request) (*http.Response, error) {
70 70
 				if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
71 71
 					return nil, err
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestNetworkRemoveError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.NetworkRemove(context.Background(), "network_id", NetworkRemoveOptions{})
... ...
@@ -29,7 +29,7 @@ func TestNetworkRemoveError(t *testing.T) {
29 29
 func TestNetworkRemove(t *testing.T) {
30 30
 	const expectedURL = "/networks/network_id"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestNodeInspectError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.NodeInspect(context.Background(), "nothing", NodeInspectOptions{})
... ...
@@ -21,7 +21,7 @@ func TestNodeInspectError(t *testing.T) {
21 21
 }
22 22
 
23 23
 func TestNodeInspectNodeNotFound(t *testing.T) {
24
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
24
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
25 25
 	assert.NilError(t, err)
26 26
 
27 27
 	_, err = client.NodeInspect(context.Background(), "unknown", NodeInspectOptions{})
... ...
@@ -29,7 +29,7 @@ func TestNodeInspectNodeNotFound(t *testing.T) {
29 29
 }
30 30
 
31 31
 func TestNodeInspectWithEmptyID(t *testing.T) {
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		return nil, errors.New("should not make request")
34 34
 	}))
35 35
 	assert.NilError(t, err)
... ...
@@ -44,7 +44,7 @@ func TestNodeInspectWithEmptyID(t *testing.T) {
44 44
 
45 45
 func TestNodeInspect(t *testing.T) {
46 46
 	const expectedURL = "/nodes/node_id"
47
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
47
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
48 48
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
49 49
 			return nil, err
50 50
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestNodeListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.NodeList(context.Background(), NodeListOptions{})
... ...
@@ -44,7 +44,7 @@ func TestNodeList(t *testing.T) {
44 44
 		},
45 45
 	}
46 46
 	for _, listCase := range listCases {
47
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
47
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
48 48
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
49 49
 				return nil, err
50 50
 			}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestNodeRemoveError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.NodeRemove(context.Background(), "node_id", NodeRemoveOptions{Force: false})
... ...
@@ -44,7 +44,7 @@ func TestNodeRemove(t *testing.T) {
44 44
 	}
45 45
 
46 46
 	for _, removeCase := range removeCases {
47
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
47
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
48 48
 			if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
49 49
 				return nil, err
50 50
 			}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestNodeUpdateError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.NodeUpdate(context.Background(), "node_id", NodeUpdateOptions{
... ...
@@ -39,7 +39,7 @@ func TestNodeUpdateError(t *testing.T) {
39 39
 func TestNodeUpdate(t *testing.T) {
40 40
 	const expectedURL = "/nodes/node_id/update"
41 41
 
42
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
42
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
43 43
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
44 44
 			return nil, err
45 45
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestOptionWithHostFromEnv(t *testing.T) {
14
-	c, err := NewClientWithOpts(WithHostFromEnv())
14
+	c, err := New(WithHostFromEnv())
15 15
 	assert.NilError(t, err)
16 16
 	assert.Check(t, c.client != nil)
17 17
 	assert.Check(t, is.Equal(c.basePath, ""))
... ...
@@ -27,7 +27,7 @@ func TestOptionWithHostFromEnv(t *testing.T) {
27 27
 
28 28
 	t.Setenv("DOCKER_HOST", "tcp://foo.example.com:2376/test/")
29 29
 
30
-	c, err = NewClientWithOpts(WithHostFromEnv())
30
+	c, err = New(WithHostFromEnv())
31 31
 	assert.NilError(t, err)
32 32
 	assert.Check(t, c.client != nil)
33 33
 	assert.Check(t, is.Equal(c.basePath, "/test/"))
... ...
@@ -38,14 +38,14 @@ func TestOptionWithHostFromEnv(t *testing.T) {
38 38
 
39 39
 func TestOptionWithTimeout(t *testing.T) {
40 40
 	timeout := 10 * time.Second
41
-	c, err := NewClientWithOpts(WithTimeout(timeout))
41
+	c, err := New(WithTimeout(timeout))
42 42
 	assert.NilError(t, err)
43 43
 	assert.Check(t, c.client != nil)
44 44
 	assert.Check(t, is.Equal(c.client.Timeout, timeout))
45 45
 }
46 46
 
47 47
 func TestOptionWithVersionFromEnv(t *testing.T) {
48
-	c, err := NewClientWithOpts(WithVersionFromEnv())
48
+	c, err := New(WithVersionFromEnv())
49 49
 	assert.NilError(t, err)
50 50
 	assert.Check(t, c.client != nil)
51 51
 	assert.Check(t, is.Equal(c.version, MaxAPIVersion))
... ...
@@ -53,7 +53,7 @@ func TestOptionWithVersionFromEnv(t *testing.T) {
53 53
 
54 54
 	t.Setenv("DOCKER_API_VERSION", "2.9999")
55 55
 
56
-	c, err = NewClientWithOpts(WithVersionFromEnv())
56
+	c, err = New(WithVersionFromEnv())
57 57
 	assert.NilError(t, err)
58 58
 	assert.Check(t, c.client != nil)
59 59
 	assert.Check(t, is.Equal(c.version, "2.9999"))
... ...
@@ -63,7 +63,7 @@ func TestOptionWithVersionFromEnv(t *testing.T) {
63 63
 func TestWithUserAgent(t *testing.T) {
64 64
 	const userAgent = "Magic-Client/v1.2.3"
65 65
 	t.Run("user-agent", func(t *testing.T) {
66
-		c, err := NewClientWithOpts(
66
+		c, err := New(
67 67
 			WithUserAgent(userAgent),
68 68
 			WithMockClient(func(req *http.Request) (*http.Response, error) {
69 69
 				assert.Check(t, is.Equal(req.Header.Get("User-Agent"), userAgent))
... ...
@@ -76,7 +76,7 @@ func TestWithUserAgent(t *testing.T) {
76 76
 		assert.NilError(t, c.Close())
77 77
 	})
78 78
 	t.Run("user-agent and custom headers", func(t *testing.T) {
79
-		c, err := NewClientWithOpts(
79
+		c, err := New(
80 80
 			WithUserAgent(userAgent),
81 81
 			WithHTTPHeaders(map[string]string{"User-Agent": "should-be-ignored/1.0.0", "Other-Header": "hello-world"}),
82 82
 			WithMockClient(func(req *http.Request) (*http.Response, error) {
... ...
@@ -91,7 +91,7 @@ func TestWithUserAgent(t *testing.T) {
91 91
 		assert.NilError(t, c.Close())
92 92
 	})
93 93
 	t.Run("custom headers", func(t *testing.T) {
94
-		c, err := NewClientWithOpts(
94
+		c, err := New(
95 95
 			WithHTTPHeaders(map[string]string{"User-Agent": "from-custom-headers/1.0.0", "Other-Header": "hello-world"}),
96 96
 			WithMockClient(func(req *http.Request) (*http.Response, error) {
97 97
 				assert.Check(t, is.Equal(req.Header.Get("User-Agent"), "from-custom-headers/1.0.0"))
... ...
@@ -105,7 +105,7 @@ func TestWithUserAgent(t *testing.T) {
105 105
 		assert.NilError(t, c.Close())
106 106
 	})
107 107
 	t.Run("no user-agent set", func(t *testing.T) {
108
-		c, err := NewClientWithOpts(
108
+		c, err := New(
109 109
 			WithHTTPHeaders(map[string]string{"Other-Header": "hello-world"}),
110 110
 			WithMockClient(func(req *http.Request) (*http.Response, error) {
111 111
 				assert.Check(t, is.Equal(req.Header.Get("User-Agent"), ""))
... ...
@@ -119,7 +119,7 @@ func TestWithUserAgent(t *testing.T) {
119 119
 		assert.NilError(t, c.Close())
120 120
 	})
121 121
 	t.Run("reset custom user-agent", func(t *testing.T) {
122
-		c, err := NewClientWithOpts(
122
+		c, err := New(
123 123
 			WithUserAgent(""),
124 124
 			WithHTTPHeaders(map[string]string{"User-Agent": "from-custom-headers/1.0.0", "Other-Header": "hello-world"}),
125 125
 			WithMockClient(func(req *http.Request) (*http.Response, error) {
... ...
@@ -18,7 +18,7 @@ import (
18 18
 // panics.
19 19
 func TestPingFail(t *testing.T) {
20 20
 	var withHeader bool
21
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
21
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
22 22
 		var hdr http.Header
23 23
 		if withHeader {
24 24
 			hdr = http.Header{}
... ...
@@ -48,7 +48,7 @@ func TestPingFail(t *testing.T) {
48 48
 // TestPingWithError tests the case where there is a protocol error in the ping.
49 49
 // This test is mostly just testing that there are no panics in this code path.
50 50
 func TestPingWithError(t *testing.T) {
51
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
51
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
52 52
 		return nil, errors.New("some connection error")
53 53
 	}))
54 54
 	assert.NilError(t, err)
... ...
@@ -64,7 +64,7 @@ func TestPingWithError(t *testing.T) {
64 64
 // TestPingSuccess tests that we are able to get the expected API headers/ping
65 65
 // details on success.
66 66
 func TestPingSuccess(t *testing.T) {
67
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
67
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
68 68
 		hdr := http.Header{}
69 69
 		hdr.Set("Api-Version", "awesome")
70 70
 		hdr.Set("Docker-Experimental", "true")
... ...
@@ -109,7 +109,7 @@ func TestPingHeadFallback(t *testing.T) {
109 109
 	for _, tc := range tests {
110 110
 		t.Run(http.StatusText(tc.status), func(t *testing.T) {
111 111
 			var reqs []string
112
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
112
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
113 113
 				if !strings.HasPrefix(req.URL.Path, expectedPath) {
114 114
 					return nil, fmt.Errorf("expected URL '%s', got '%s'", expectedPath, req.URL.Path)
115 115
 				}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestPluginDisableError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.PluginDisable(context.Background(), "plugin_name", PluginDisableOptions{})
... ...
@@ -29,7 +29,7 @@ func TestPluginDisableError(t *testing.T) {
29 29
 func TestPluginDisable(t *testing.T) {
30 30
 	const expectedURL = "/plugins/plugin_name/disable"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestPluginEnableError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.PluginEnable(context.Background(), "plugin_name", PluginEnableOptions{})
... ...
@@ -29,7 +29,7 @@ func TestPluginEnableError(t *testing.T) {
29 29
 func TestPluginEnable(t *testing.T) {
30 30
 	const expectedURL = "/plugins/plugin_name/enable"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestPluginInspectError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.PluginInspect(t.Context(), "nothing", PluginInspectOptions{})
... ...
@@ -20,7 +20,7 @@ func TestPluginInspectError(t *testing.T) {
20 20
 }
21 21
 
22 22
 func TestPluginInspectWithEmptyID(t *testing.T) {
23
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
23
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
24 24
 		return nil, errors.New("should not make request")
25 25
 	}))
26 26
 	assert.NilError(t, err)
... ...
@@ -35,7 +35,7 @@ func TestPluginInspectWithEmptyID(t *testing.T) {
35 35
 
36 36
 func TestPluginInspect(t *testing.T) {
37 37
 	const expectedURL = "/plugins/plugin_name"
38
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
38
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
39 39
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
40 40
 			return nil, err
41 41
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestPluginListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.PluginList(context.Background(), PluginListOptions{})
... ...
@@ -53,7 +53,7 @@ func TestPluginList(t *testing.T) {
53 53
 	}
54 54
 
55 55
 	for _, listCase := range listCases {
56
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
56
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
57 57
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
58 58
 				return nil, err
59 59
 			}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestPluginPushError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.PluginPush(context.Background(), "plugin_name", PluginPushOptions{})
... ...
@@ -31,7 +31,7 @@ func TestPluginPushError(t *testing.T) {
31 31
 func TestPluginPush(t *testing.T) {
32 32
 	const expectedURL = "/plugins/plugin_name"
33 33
 
34
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
34
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
35 35
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
36 36
 			return nil, err
37 37
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestPluginRemoveError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.PluginRemove(context.Background(), "plugin_name", PluginRemoveOptions{})
... ...
@@ -29,7 +29,7 @@ func TestPluginRemoveError(t *testing.T) {
29 29
 func TestPluginRemove(t *testing.T) {
30 30
 	const expectedURL = "/plugins/plugin_name"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestPluginSetError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.PluginSet(context.Background(), "plugin_name", PluginSetOptions{})
... ...
@@ -29,7 +29,7 @@ func TestPluginSetError(t *testing.T) {
29 29
 func TestPluginSet(t *testing.T) {
30 30
 	const expectedURL = "/plugins/plugin_name/set"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -50,7 +50,7 @@ func TestSetHostHeader(t *testing.T) {
50 50
 
51 51
 	for _, tc := range testCases {
52 52
 		t.Run(tc.host, func(t *testing.T) {
53
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
53
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
54 54
 				if err := assertRequest(req, http.MethodGet, testEndpoint); err != nil {
55 55
 					return nil, err
56 56
 				}
... ...
@@ -74,7 +74,7 @@ func TestSetHostHeader(t *testing.T) {
74 74
 // API versions < 1.24 returned plain text errors, but we may encounter
75 75
 // other situations where a non-JSON error is returned.
76 76
 func TestPlainTextError(t *testing.T) {
77
-	client, err := NewClientWithOpts(WithMockClient(mockResponse(http.StatusInternalServerError, nil, "Server error")))
77
+	client, err := New(WithMockClient(mockResponse(http.StatusInternalServerError, nil, "Server error")))
78 78
 	assert.NilError(t, err)
79 79
 	_, err = client.ContainerList(context.Background(), ContainerListOptions{})
80 80
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -195,11 +195,11 @@ func TestResponseErrors(t *testing.T) {
195 195
 	}
196 196
 	for _, tc := range tests {
197 197
 		t.Run(tc.doc, func(t *testing.T) {
198
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
198
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
199 199
 				return mockResponse(http.StatusBadRequest, http.Header{"Content-Type": []string{tc.contentType}}, tc.response)(req)
200 200
 			}))
201 201
 			if tc.apiVersion != "" {
202
-				client, err = NewClientWithOpts(WithHTTPClient(client.client), WithVersion(tc.apiVersion))
202
+				client, err = New(WithHTTPClient(client.client), WithVersion(tc.apiVersion))
203 203
 			}
204 204
 			assert.NilError(t, err)
205 205
 			_, err = client.Ping(t.Context(), PingOptions{})
... ...
@@ -211,7 +211,7 @@ func TestResponseErrors(t *testing.T) {
211 211
 
212 212
 func TestInfiniteError(t *testing.T) {
213 213
 	infinitR := rand.New(rand.NewSource(42))
214
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
214
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
215 215
 		resp := &http.Response{
216 216
 			StatusCode: http.StatusInternalServerError,
217 217
 			Header:     http.Header{},
... ...
@@ -229,7 +229,7 @@ func TestInfiniteError(t *testing.T) {
229 229
 func TestCanceledContext(t *testing.T) {
230 230
 	const testEndpoint = "/test"
231 231
 
232
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
232
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
233 233
 		assert.Check(t, is.ErrorType(req.Context().Err(), context.Canceled))
234 234
 		return nil, context.Canceled
235 235
 	}))
... ...
@@ -245,7 +245,7 @@ func TestCanceledContext(t *testing.T) {
245 245
 func TestDeadlineExceededContext(t *testing.T) {
246 246
 	const testEndpoint = "/test"
247 247
 
248
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
248
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
249 249
 		assert.Check(t, is.ErrorType(req.Context().Err(), context.DeadlineExceeded))
250 250
 		return nil, context.DeadlineExceeded
251 251
 	}))
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestSecretCreateError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 	_, err = client.SecretCreate(context.Background(), SecretCreateOptions{})
18 18
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -20,7 +20,7 @@ func TestSecretCreateError(t *testing.T) {
20 20
 
21 21
 func TestSecretCreate(t *testing.T) {
22 22
 	const expectedURL = "/secrets/create"
23
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
23
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
24 24
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
25 25
 			return nil, err
26 26
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestSecretInspectError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.SecretInspect(context.Background(), "nothing", SecretInspectOptions{})
... ...
@@ -21,7 +21,7 @@ func TestSecretInspectError(t *testing.T) {
21 21
 }
22 22
 
23 23
 func TestSecretInspectSecretNotFound(t *testing.T) {
24
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
24
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
25 25
 	assert.NilError(t, err)
26 26
 
27 27
 	_, err = client.SecretInspect(context.Background(), "unknown", SecretInspectOptions{})
... ...
@@ -29,7 +29,7 @@ func TestSecretInspectSecretNotFound(t *testing.T) {
29 29
 }
30 30
 
31 31
 func TestSecretInspectWithEmptyID(t *testing.T) {
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		return nil, errors.New("should not make request")
34 34
 	}))
35 35
 	assert.NilError(t, err)
... ...
@@ -44,7 +44,7 @@ func TestSecretInspectWithEmptyID(t *testing.T) {
44 44
 
45 45
 func TestSecretInspect(t *testing.T) {
46 46
 	const expectedURL = "/secrets/secret_id"
47
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
47
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
48 48
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
49 49
 			return nil, err
50 50
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestSecretListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.SecretList(context.Background(), SecretListOptions{})
... ...
@@ -43,7 +43,7 @@ func TestSecretList(t *testing.T) {
43 43
 		},
44 44
 	}
45 45
 	for _, listCase := range listCases {
46
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
46
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
47 47
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
48 48
 				return nil, err
49 49
 			}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestSecretRemoveError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.SecretRemove(context.Background(), "secret_id", SecretRemoveOptions{})
... ...
@@ -29,7 +29,7 @@ func TestSecretRemoveError(t *testing.T) {
29 29
 func TestSecretRemove(t *testing.T) {
30 30
 	const expectedURL = "/secrets/secret_id"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestSecretUpdateError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.SecretUpdate(context.Background(), "secret_id", SecretUpdateOptions{})
... ...
@@ -29,7 +29,7 @@ func TestSecretUpdateError(t *testing.T) {
29 29
 func TestSecretUpdate(t *testing.T) {
30 30
 	const expectedURL = "/secrets/secret_id/update"
31 31
 
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
34 34
 			return nil, err
35 35
 		}
... ...
@@ -18,7 +18,7 @@ import (
18 18
 )
19 19
 
20 20
 func TestServiceCreateError(t *testing.T) {
21
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
21
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
22 22
 	assert.NilError(t, err)
23 23
 	_, err = client.ServiceCreate(t.Context(), ServiceCreateOptions{})
24 24
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -29,7 +29,7 @@ func TestServiceCreateError(t *testing.T) {
29 29
 //
30 30
 // Regression test for https://github.com/docker/cli/issues/4890
31 31
 func TestServiceCreateConnectionError(t *testing.T) {
32
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
32
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
33 33
 	assert.NilError(t, err)
34 34
 
35 35
 	_, err = client.ServiceCreate(t.Context(), ServiceCreateOptions{})
... ...
@@ -38,7 +38,7 @@ func TestServiceCreateConnectionError(t *testing.T) {
38 38
 
39 39
 func TestServiceCreate(t *testing.T) {
40 40
 	const expectedURL = "/services/create"
41
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
41
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
42 42
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
43 43
 			return nil, err
44 44
 		}
... ...
@@ -54,7 +54,7 @@ func TestServiceCreate(t *testing.T) {
54 54
 }
55 55
 
56 56
 func TestServiceCreateCompatiblePlatforms(t *testing.T) {
57
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
57
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
58 58
 		if strings.HasPrefix(req.URL.Path, defaultAPIPath+"/services/create") {
59 59
 			var serviceSpec swarm.ServiceSpec
60 60
 
... ...
@@ -123,7 +123,7 @@ func TestServiceCreateDigestPinning(t *testing.T) {
123 123
 		{"cannotresolve", "cannotresolve:latest"},
124 124
 	}
125 125
 
126
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
126
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
127 127
 		if strings.HasPrefix(req.URL.Path, defaultAPIPath+"/services/create") {
128 128
 			// reset and set image received by the service create endpoint
129 129
 			serviceCreateImage = ""
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestServiceInspectError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.ServiceInspect(context.Background(), "nothing", ServiceInspectOptions{})
... ...
@@ -21,7 +21,7 @@ func TestServiceInspectError(t *testing.T) {
21 21
 }
22 22
 
23 23
 func TestServiceInspectServiceNotFound(t *testing.T) {
24
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
24
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
25 25
 	assert.NilError(t, err)
26 26
 
27 27
 	_, err = client.ServiceInspect(context.Background(), "unknown", ServiceInspectOptions{})
... ...
@@ -29,7 +29,7 @@ func TestServiceInspectServiceNotFound(t *testing.T) {
29 29
 }
30 30
 
31 31
 func TestServiceInspectWithEmptyID(t *testing.T) {
32
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
32
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
33 33
 		return nil, errors.New("should not make request")
34 34
 	}))
35 35
 	assert.NilError(t, err)
... ...
@@ -44,7 +44,7 @@ func TestServiceInspectWithEmptyID(t *testing.T) {
44 44
 
45 45
 func TestServiceInspect(t *testing.T) {
46 46
 	const expectedURL = "/services/service_id"
47
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
47
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
48 48
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
49 49
 			return nil, err
50 50
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestServiceListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.ServiceList(context.Background(), ServiceListOptions{})
... ...
@@ -43,7 +43,7 @@ func TestServiceList(t *testing.T) {
43 43
 		},
44 44
 	}
45 45
 	for _, listCase := range listCases {
46
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
46
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
47 47
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
48 48
 				return nil, err
49 49
 			}
... ...
@@ -17,7 +17,7 @@ import (
17 17
 )
18 18
 
19 19
 func TestServiceLogsError(t *testing.T) {
20
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
20
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
21 21
 	assert.NilError(t, err)
22 22
 	_, err = client.ServiceLogs(t.Context(), "service_id", ServiceLogsOptions{})
23 23
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -99,7 +99,7 @@ func TestServiceLogs(t *testing.T) {
99 99
 	}
100 100
 	for _, tc := range cases {
101 101
 		t.Run(tc.doc, func(t *testing.T) {
102
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
102
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
103 103
 				if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
104 104
 					return nil, err
105 105
 				}
... ...
@@ -129,10 +129,13 @@ func TestServiceLogs(t *testing.T) {
129 129
 }
130 130
 
131 131
 func ExampleClient_ServiceLogs_withTimeout() {
132
+	client, err := New(FromEnv, WithAPIVersionNegotiation())
133
+	if err != nil {
134
+		log.Fatal(err)
135
+	}
136
+
132 137
 	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
133 138
 	defer cancel()
134
-
135
-	client, _ := NewClientWithOpts(FromEnv)
136 139
 	res, err := client.ServiceLogs(ctx, "service_id", ServiceLogsOptions{})
137 140
 	if err != nil {
138 141
 		log.Fatal(err)
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestServiceRemoveError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.ServiceRemove(context.Background(), "service_id", ServiceRemoveOptions{})
... ...
@@ -27,7 +27,7 @@ func TestServiceRemoveError(t *testing.T) {
27 27
 }
28 28
 
29 29
 func TestServiceRemoveNotFoundError(t *testing.T) {
30
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "no such service: service_id")))
30
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "no such service: service_id")))
31 31
 	assert.NilError(t, err)
32 32
 
33 33
 	_, err = client.ServiceRemove(context.Background(), "service_id", ServiceRemoveOptions{})
... ...
@@ -38,7 +38,7 @@ func TestServiceRemoveNotFoundError(t *testing.T) {
38 38
 func TestServiceRemove(t *testing.T) {
39 39
 	const expectedURL = "/services/service_id"
40 40
 
41
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
41
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
42 42
 		if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
43 43
 			return nil, err
44 44
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestServiceUpdateError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.ServiceUpdate(t.Context(), "service_id", ServiceUpdateOptions{})
... ...
@@ -32,7 +32,7 @@ func TestServiceUpdateError(t *testing.T) {
32 32
 //
33 33
 // Regression test for https://github.com/docker/cli/issues/4890
34 34
 func TestServiceUpdateConnectionError(t *testing.T) {
35
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
35
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
36 36
 	assert.NilError(t, err)
37 37
 
38 38
 	_, err = client.ServiceUpdate(t.Context(), "service_id", ServiceUpdateOptions{})
... ...
@@ -64,7 +64,7 @@ func TestServiceUpdate(t *testing.T) {
64 64
 	}
65 65
 
66 66
 	for _, updateCase := range updateCases {
67
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
67
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
68 68
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
69 69
 				return nil, err
70 70
 			}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestSwarmGetUnlockKeyError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.SwarmGetUnlockKey(context.Background())
... ...
@@ -25,7 +25,7 @@ func TestSwarmGetUnlockKey(t *testing.T) {
25 25
 		unlockKey   = "SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeE"
26 26
 	)
27 27
 
28
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
28
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
29 29
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
30 30
 			return nil, err
31 31
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestSwarmInitError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.SwarmInit(context.Background(), SwarmInitOptions{})
... ...
@@ -21,7 +21,7 @@ func TestSwarmInitError(t *testing.T) {
21 21
 func TestSwarmInit(t *testing.T) {
22 22
 	const expectedURL = "/swarm/init"
23 23
 
24
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
24
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
25 25
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
26 26
 			return nil, err
27 27
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestSwarmInspectError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.SwarmInspect(t.Context(), SwarmInspectOptions{})
... ...
@@ -20,7 +20,7 @@ func TestSwarmInspectError(t *testing.T) {
20 20
 
21 21
 func TestSwarmInspect(t *testing.T) {
22 22
 	const expectedURL = "/swarm"
23
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
23
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
24 24
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
25 25
 			return nil, err
26 26
 		}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestSwarmJoinError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.SwarmJoin(context.Background(), SwarmJoinOptions{})
... ...
@@ -21,7 +21,7 @@ func TestSwarmJoinError(t *testing.T) {
21 21
 func TestSwarmJoin(t *testing.T) {
22 22
 	const expectedURL = "/swarm/join"
23 23
 
24
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
24
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
25 25
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
26 26
 			return nil, err
27 27
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestSwarmLeaveError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.SwarmLeave(context.Background(), SwarmLeaveOptions{})
... ...
@@ -36,7 +36,7 @@ func TestSwarmLeave(t *testing.T) {
36 36
 	}
37 37
 
38 38
 	for _, leaveCase := range leaveCases {
39
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
39
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
40 40
 			if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
41 41
 				return nil, err
42 42
 			}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestSwarmUnlockError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.SwarmUnlock(context.Background(), SwarmUnlockOptions{Key: "SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"})
... ...
@@ -21,7 +21,7 @@ func TestSwarmUnlockError(t *testing.T) {
21 21
 func TestSwarmUnlock(t *testing.T) {
22 22
 	const expectedURL = "/swarm/unlock"
23 23
 
24
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
24
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
25 25
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
26 26
 			return nil, err
27 27
 		}
... ...
@@ -10,7 +10,7 @@ import (
10 10
 )
11 11
 
12 12
 func TestSwarmUpdateError(t *testing.T) {
13
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
13
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14 14
 	assert.NilError(t, err)
15 15
 
16 16
 	_, err = client.SwarmUpdate(t.Context(), SwarmUpdateOptions{})
... ...
@@ -20,7 +20,7 @@ func TestSwarmUpdateError(t *testing.T) {
20 20
 func TestSwarmUpdate(t *testing.T) {
21 21
 	const expectedURL = "/swarm/update"
22 22
 
23
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
23
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
24 24
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
25 25
 			return nil, err
26 26
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestDiskUsageError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 	_, err = client.DiskUsage(context.Background(), DiskUsageOptions{})
18 18
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
... ...
@@ -20,7 +20,7 @@ func TestDiskUsageError(t *testing.T) {
20 20
 
21 21
 func TestDiskUsage(t *testing.T) {
22 22
 	const expectedURL = "/system/df"
23
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
23
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
24 24
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
25 25
 			return nil, err
26 26
 		}
... ...
@@ -35,7 +35,7 @@ func TestEventsErrorInOptions(t *testing.T) {
35 35
 		},
36 36
 	}
37 37
 	for _, tc := range errorCases {
38
-		client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
38
+		client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
39 39
 		assert.NilError(t, err)
40 40
 		events := client.Events(context.Background(), tc.options)
41 41
 		err = <-events.Err
... ...
@@ -44,7 +44,7 @@ func TestEventsErrorInOptions(t *testing.T) {
44 44
 }
45 45
 
46 46
 func TestEventsErrorFromServer(t *testing.T) {
47
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
47
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
48 48
 	assert.NilError(t, err)
49 49
 	events := client.Events(context.Background(), EventsListOptions{})
50 50
 	err = <-events.Err
... ...
@@ -106,7 +106,7 @@ func TestEvents(t *testing.T) {
106 106
 	}
107 107
 
108 108
 	for _, eventsCase := range eventsCases {
109
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
109
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
110 110
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
111 111
 				return nil, err
112 112
 			}
... ...
@@ -12,14 +12,14 @@ import (
12 12
 )
13 13
 
14 14
 func TestInfoServerError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 	_, err = client.Info(context.Background(), InfoOptions{})
18 18
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
19 19
 }
20 20
 
21 21
 func TestInfoInvalidResponseJSONError(t *testing.T) {
22
-	client, err := NewClientWithOpts(WithMockClient(mockResponse(http.StatusOK, nil, "invalid json")))
22
+	client, err := New(WithMockClient(mockResponse(http.StatusOK, nil, "invalid json")))
23 23
 	assert.NilError(t, err)
24 24
 	_, err = client.Info(context.Background(), InfoOptions{})
25 25
 	assert.Check(t, is.ErrorContains(err, "invalid character"))
... ...
@@ -27,7 +27,7 @@ func TestInfoInvalidResponseJSONError(t *testing.T) {
27 27
 
28 28
 func TestInfo(t *testing.T) {
29 29
 	const expectedURL = "/info"
30
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
30
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
31 31
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
32 32
 			return nil, err
33 33
 		}
... ...
@@ -48,7 +48,7 @@ func TestInfo(t *testing.T) {
48 48
 
49 49
 func TestInfoWithDiscoveredDevices(t *testing.T) {
50 50
 	const expectedURL = "/info"
51
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
51
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
52 52
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
53 53
 			return nil, err
54 54
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestTaskInspectError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.TaskInspect(context.Background(), "nothing", TaskInspectOptions{})
... ...
@@ -21,7 +21,7 @@ func TestTaskInspectError(t *testing.T) {
21 21
 }
22 22
 
23 23
 func TestTaskInspectWithEmptyID(t *testing.T) {
24
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
24
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
25 25
 		return nil, errors.New("should not make request")
26 26
 	}))
27 27
 	assert.NilError(t, err)
... ...
@@ -36,7 +36,7 @@ func TestTaskInspectWithEmptyID(t *testing.T) {
36 36
 
37 37
 func TestTaskInspect(t *testing.T) {
38 38
 	const expectedURL = "/tasks/task_id"
39
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
39
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
40 40
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
41 41
 			return nil, err
42 42
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestTaskListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.TaskList(context.Background(), TaskListOptions{})
... ...
@@ -43,7 +43,7 @@ func TestTaskList(t *testing.T) {
43 43
 		},
44 44
 	}
45 45
 	for _, listCase := range listCases {
46
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
46
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
47 47
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
48 48
 				return nil, err
49 49
 			}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestVolumeCreateError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.VolumeCreate(context.Background(), VolumeCreateOptions{})
... ...
@@ -22,7 +22,7 @@ func TestVolumeCreateError(t *testing.T) {
22 22
 func TestVolumeCreate(t *testing.T) {
23 23
 	const expectedURL = "/volumes/create"
24 24
 
25
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
25
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
26 26
 		if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
27 27
 			return nil, err
28 28
 		}
... ...
@@ -12,7 +12,7 @@ import (
12 12
 )
13 13
 
14 14
 func TestVolumeInspectError(t *testing.T) {
15
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16 16
 	assert.NilError(t, err)
17 17
 
18 18
 	_, err = client.VolumeInspect(t.Context(), "nothing", VolumeInspectOptions{})
... ...
@@ -20,7 +20,7 @@ func TestVolumeInspectError(t *testing.T) {
20 20
 }
21 21
 
22 22
 func TestVolumeInspectNotFound(t *testing.T) {
23
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
23
+	client, err := New(WithMockClient(errorMock(http.StatusNotFound, "Server error")))
24 24
 	assert.NilError(t, err)
25 25
 
26 26
 	_, err = client.VolumeInspect(t.Context(), "unknown", VolumeInspectOptions{})
... ...
@@ -28,7 +28,7 @@ func TestVolumeInspectNotFound(t *testing.T) {
28 28
 }
29 29
 
30 30
 func TestVolumeInspectWithEmptyID(t *testing.T) {
31
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
31
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
32 32
 		return nil, errors.New("should not make request")
33 33
 	}))
34 34
 	assert.NilError(t, err)
... ...
@@ -49,7 +49,7 @@ func TestVolumeInspect(t *testing.T) {
49 49
 		Mountpoint: "mountpoint",
50 50
 	}
51 51
 
52
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
52
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
53 53
 		if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
54 54
 			return nil, err
55 55
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestVolumeListError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.VolumeList(context.Background(), VolumeListOptions{})
... ...
@@ -42,7 +42,7 @@ func TestVolumeList(t *testing.T) {
42 42
 	}
43 43
 
44 44
 	for _, listCase := range listCases {
45
-		client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
45
+		client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
46 46
 			if err := assertRequest(req, http.MethodGet, expectedURL); err != nil {
47 47
 				return nil, err
48 48
 			}
... ...
@@ -63,7 +63,7 @@ func TestVolumePrune(t *testing.T) {
63 63
 	}
64 64
 	for _, tc := range tests {
65 65
 		t.Run(tc.doc, func(t *testing.T) {
66
-			client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
66
+			client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
67 67
 				if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
68 68
 					return nil, err
69 69
 				}
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestVolumeRemoveError(t *testing.T) {
14
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
14
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	_, err = client.VolumeRemove(t.Context(), "volume_id", VolumeRemoveOptions{})
... ...
@@ -31,7 +31,7 @@ func TestVolumeRemoveError(t *testing.T) {
31 31
 //
32 32
 // Regression test for https://github.com/docker/cli/issues/4890
33 33
 func TestVolumeRemoveConnectionError(t *testing.T) {
34
-	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
34
+	client, err := New(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
35 35
 	assert.NilError(t, err)
36 36
 
37 37
 	_, err = client.VolumeRemove(t.Context(), "volume_id", VolumeRemoveOptions{})
... ...
@@ -41,7 +41,7 @@ func TestVolumeRemoveConnectionError(t *testing.T) {
41 41
 func TestVolumeRemove(t *testing.T) {
42 42
 	const expectedURL = "/volumes/volume_id"
43 43
 
44
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
44
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
45 45
 		if err := assertRequest(req, http.MethodDelete, expectedURL); err != nil {
46 46
 			return nil, err
47 47
 		}
... ...
@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 func TestVolumeUpdateError(t *testing.T) {
16
-	client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
16
+	client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	_, err = client.VolumeUpdate(t.Context(), "volume", VolumeUpdateOptions{})
... ...
@@ -34,7 +34,7 @@ func TestVolumeUpdate(t *testing.T) {
34 34
 		expectedVersion = "version=10"
35 35
 	)
36 36
 
37
-	client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
37
+	client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
38 38
 		if err := assertRequest(req, http.MethodPut, expectedURL); err != nil {
39 39
 			return nil, err
40 40
 		}
... ...
@@ -85,7 +85,7 @@ func (d *Daemon) inspectFieldWithError(name, field string) (string, error) {
85 85
 func (d *Daemon) CheckActiveContainerCount(ctx context.Context) func(t *testing.T) (any, string) {
86 86
 	return func(t *testing.T) (any, string) {
87 87
 		t.Helper()
88
-		apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithHost(d.Sock()))
88
+		apiClient, err := client.New(client.FromEnv, client.WithHost(d.Sock()))
89 89
 		assert.NilError(t, err)
90 90
 
91 91
 		list, err := apiClient.ContainerList(ctx, client.ContainerListOptions{})
... ...
@@ -177,7 +177,7 @@ func (s *DockerAPISuite) TestPostContainersAttach(c *testing.T) {
177 177
 	expectTimeout(wc, br, "stdout")
178 178
 
179 179
 	// Test the client API
180
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
180
+	apiClient, err := client.New(client.FromEnv)
181 181
 	assert.NilError(c, err)
182 182
 	defer apiClient.Close()
183 183
 
... ...
@@ -37,7 +37,7 @@ func (s *DockerAPISuite) TestContainerAPIGetAll(c *testing.T) {
37 37
 	const name = "getall"
38 38
 	cli.DockerCmd(c, "run", "--name", name, "busybox", "true")
39 39
 
40
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
40
+	apiClient, err := client.New(client.FromEnv)
41 41
 	assert.NilError(c, err)
42 42
 	defer apiClient.Close()
43 43
 
... ...
@@ -56,7 +56,7 @@ func (s *DockerAPISuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) {
56 56
 	startCount := getContainerCount(c)
57 57
 	cli.DockerCmd(c, "run", "busybox", "true")
58 58
 
59
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
59
+	apiClient, err := client.New(client.FromEnv)
60 60
 	assert.NilError(c, err)
61 61
 	defer apiClient.Close()
62 62
 
... ...
@@ -99,7 +99,7 @@ func (s *DockerAPISuite) TestContainerAPIGetExport(c *testing.T) {
99 99
 	const name = "exportcontainer"
100 100
 	cli.DockerCmd(c, "run", "--name", name, "busybox", "touch", "/test")
101 101
 
102
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
102
+	apiClient, err := client.New(client.FromEnv)
103 103
 	assert.NilError(c, err)
104 104
 	defer apiClient.Close()
105 105
 
... ...
@@ -126,7 +126,7 @@ func (s *DockerAPISuite) TestContainerAPIGetChanges(c *testing.T) {
126 126
 	const name = "changescontainer"
127 127
 	cli.DockerCmd(c, "run", "--name", name, "busybox", "rm", "/etc/passwd")
128 128
 
129
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
129
+	apiClient, err := client.New(client.FromEnv)
130 130
 	assert.NilError(c, err)
131 131
 	defer apiClient.Close()
132 132
 
... ...
@@ -154,7 +154,7 @@ func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) {
154 154
 
155 155
 	bc := make(chan b, 1)
156 156
 	go func() {
157
-		apiClient, err := client.NewClientWithOpts(client.FromEnv)
157
+		apiClient, err := client.New(client.FromEnv)
158 158
 		assert.NilError(c, err)
159 159
 		defer apiClient.Close()
160 160
 
... ...
@@ -190,7 +190,7 @@ func (s *DockerAPISuite) TestGetContainerStatsRmRunning(c *testing.T) {
190 190
 	buf := &ChannelBuffer{C: make(chan []byte, 1)}
191 191
 	defer buf.Close()
192 192
 
193
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
193
+	apiClient, err := client.New(client.FromEnv)
194 194
 	assert.NilError(c, err)
195 195
 	defer apiClient.Close()
196 196
 
... ...
@@ -263,7 +263,7 @@ func (s *DockerAPISuite) TestGetContainerStatsStream(c *testing.T) {
263 263
 
264 264
 	bc := make(chan b, 1)
265 265
 	go func() {
266
-		apiClient, err := client.NewClientWithOpts(client.FromEnv)
266
+		apiClient, err := client.New(client.FromEnv)
267 267
 		assert.NilError(c, err)
268 268
 		defer apiClient.Close()
269 269
 
... ...
@@ -300,7 +300,7 @@ func (s *DockerAPISuite) TestGetContainerStatsNoStream(c *testing.T) {
300 300
 	cID := runSleepingContainer(c, "--name", name)
301 301
 	defer cli.DockerCmd(c, "rm", "-f", cID)
302 302
 
303
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
303
+	apiClient, err := client.New(client.FromEnv)
304 304
 	assert.NilError(c, err)
305 305
 	defer apiClient.Close()
306 306
 
... ...
@@ -328,7 +328,7 @@ func (s *DockerAPISuite) TestGetStoppedContainerStats(c *testing.T) {
328 328
 	cli.DockerCmd(c, "create", "--name", name, "busybox", "ps")
329 329
 	defer cli.DockerCmd(c, "rm", "-f", name)
330 330
 
331
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
331
+	apiClient, err := client.New(client.FromEnv)
332 332
 	assert.NilError(c, err)
333 333
 	defer apiClient.Close()
334 334
 
... ...
@@ -362,7 +362,7 @@ func (s *DockerAPISuite) TestContainerAPIPause(c *testing.T) {
362 362
 	out := cli.DockerCmd(c, "run", "-d", "busybox", "sleep", "30").Combined()
363 363
 	ContainerID := strings.TrimSpace(out)
364 364
 
365
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
365
+	apiClient, err := client.New(client.FromEnv)
366 366
 	assert.NilError(c, err)
367 367
 	defer apiClient.Close()
368 368
 
... ...
@@ -388,7 +388,7 @@ func (s *DockerAPISuite) TestContainerAPITop(c *testing.T) {
388 388
 	id := strings.TrimSpace(out)
389 389
 	cli.WaitRun(c, id)
390 390
 
391
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
391
+	apiClient, err := client.New(client.FromEnv)
392 392
 	assert.NilError(c, err)
393 393
 	defer apiClient.Close()
394 394
 
... ...
@@ -410,7 +410,7 @@ func (s *DockerAPISuite) TestContainerAPITopWindows(c *testing.T) {
410 410
 	id := runSleepingContainer(c, "-d")
411 411
 	cli.WaitRun(c, id)
412 412
 
413
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
413
+	apiClient, err := client.New(client.FromEnv)
414 414
 	assert.NilError(c, err)
415 415
 	defer apiClient.Close()
416 416
 
... ...
@@ -439,7 +439,7 @@ func (s *DockerAPISuite) TestContainerAPICommit(c *testing.T) {
439 439
 	const cName = "testapicommit"
440 440
 	cli.DockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
441 441
 
442
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
442
+	apiClient, err := client.New(client.FromEnv)
443 443
 	assert.NilError(c, err)
444 444
 	defer apiClient.Close()
445 445
 
... ...
@@ -461,7 +461,7 @@ func (s *DockerAPISuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
461 461
 	const cName = "testapicommitwithconfig"
462 462
 	cli.DockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
463 463
 
464
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
464
+	apiClient, err := client.New(client.FromEnv)
465 465
 	assert.NilError(c, err)
466 466
 	defer apiClient.Close()
467 467
 
... ...
@@ -508,7 +508,7 @@ func (s *DockerAPISuite) TestContainerAPIBadPort(c *testing.T) {
508 508
 		},
509 509
 	}
510 510
 
511
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
511
+	apiClient, err := client.New(client.FromEnv)
512 512
 	assert.NilError(c, err)
513 513
 	defer apiClient.Close()
514 514
 
... ...
@@ -526,7 +526,7 @@ func (s *DockerAPISuite) TestContainerAPICreate(c *testing.T) {
526 526
 		Cmd:   []string{"/bin/sh", "-c", "touch /test && ls /test"},
527 527
 	}
528 528
 
529
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
529
+	apiClient, err := client.New(client.FromEnv)
530 530
 	assert.NilError(c, err)
531 531
 	defer apiClient.Close()
532 532
 
... ...
@@ -542,7 +542,7 @@ func (s *DockerAPISuite) TestContainerAPICreate(c *testing.T) {
542 542
 }
543 543
 
544 544
 func (s *DockerAPISuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
545
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
545
+	apiClient, err := client.New(client.FromEnv)
546 546
 	assert.NilError(c, err)
547 547
 	defer apiClient.Close()
548 548
 
... ...
@@ -577,7 +577,7 @@ func UtilCreateNetworkMode(t *testing.T, networkMode container.NetworkMode) {
577 577
 		NetworkMode: networkMode,
578 578
 	}
579 579
 
580
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
580
+	apiClient, err := client.New(client.FromEnv)
581 581
 	assert.NilError(t, err)
582 582
 	defer apiClient.Close()
583 583
 
... ...
@@ -608,7 +608,7 @@ func (s *DockerAPISuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T)
608 608
 		},
609 609
 	}
610 610
 
611
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
611
+	apiClient, err := client.New(client.FromEnv)
612 612
 	assert.NilError(c, err)
613 613
 	defer apiClient.Close()
614 614
 
... ...
@@ -709,7 +709,7 @@ func (s *DockerAPISuite) TestContainerAPIKill(c *testing.T) {
709 709
 	const name = "test-api-kill"
710 710
 	runSleepingContainer(c, "-i", "--name", name)
711 711
 
712
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
712
+	apiClient, err := client.New(client.FromEnv)
713 713
 	assert.NilError(c, err)
714 714
 	defer apiClient.Close()
715 715
 
... ...
@@ -725,7 +725,7 @@ func (s *DockerAPISuite) TestContainerAPIKill(c *testing.T) {
725 725
 func (s *DockerAPISuite) TestContainerAPIRestart(c *testing.T) {
726 726
 	const name = "test-api-restart"
727 727
 	runSleepingContainer(c, "-di", "--name", name)
728
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
728
+	apiClient, err := client.New(client.FromEnv)
729 729
 	assert.NilError(c, err)
730 730
 	defer apiClient.Close()
731 731
 
... ...
@@ -743,7 +743,7 @@ func (s *DockerAPISuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
743 743
 	id := runSleepingContainer(c, "-di", "--name", name)
744 744
 	cli.WaitRun(c, id)
745 745
 
746
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
746
+	apiClient, err := client.New(client.FromEnv)
747 747
 	assert.NilError(c, err)
748 748
 	defer apiClient.Close()
749 749
 
... ...
@@ -761,7 +761,7 @@ func (s *DockerAPISuite) TestContainerAPIStart(c *testing.T) {
761 761
 		OpenStdin: true,
762 762
 	}
763 763
 
764
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
764
+	apiClient, err := client.New(client.FromEnv)
765 765
 	assert.NilError(c, err)
766 766
 	defer apiClient.Close()
767 767
 
... ...
@@ -789,7 +789,7 @@ func (s *DockerAPISuite) TestContainerAPIStop(c *testing.T) {
789 789
 	runSleepingContainer(c, "-i", "--name", name)
790 790
 	timeout := 30
791 791
 
792
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
792
+	apiClient, err := client.New(client.FromEnv)
793 793
 	assert.NilError(c, err)
794 794
 	defer apiClient.Close()
795 795
 
... ...
@@ -816,7 +816,7 @@ func (s *DockerAPISuite) TestContainerAPIWait(c *testing.T) {
816 816
 	}
817 817
 	cli.DockerCmd(c, "run", "--name", name, "busybox", sleepCmd, "2")
818 818
 
819
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
819
+	apiClient, err := client.New(client.FromEnv)
820 820
 	assert.NilError(c, err)
821 821
 	defer apiClient.Close()
822 822
 
... ...
@@ -835,7 +835,7 @@ func (s *DockerAPISuite) TestContainerAPIDelete(c *testing.T) {
835 835
 	cli.WaitRun(c, id)
836 836
 	cli.DockerCmd(c, "stop", id)
837 837
 
838
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
838
+	apiClient, err := client.New(client.FromEnv)
839 839
 	assert.NilError(c, err)
840 840
 	defer apiClient.Close()
841 841
 
... ...
@@ -844,7 +844,7 @@ func (s *DockerAPISuite) TestContainerAPIDelete(c *testing.T) {
844 844
 }
845 845
 
846 846
 func (s *DockerAPISuite) TestContainerAPIDeleteNotExist(c *testing.T) {
847
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
847
+	apiClient, err := client.New(client.FromEnv)
848 848
 	assert.NilError(c, err)
849 849
 	defer apiClient.Close()
850 850
 
... ...
@@ -860,7 +860,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteForce(c *testing.T) {
860 860
 		Force: true,
861 861
 	}
862 862
 
863
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
863
+	apiClient, err := client.New(client.FromEnv)
864 864
 	assert.NilError(c, err)
865 865
 	defer apiClient.Close()
866 866
 
... ...
@@ -886,7 +886,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
886 886
 		RemoveLinks: true,
887 887
 	}
888 888
 
889
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
889
+	apiClient, err := client.New(client.FromEnv)
890 890
 	assert.NilError(c, err)
891 891
 	defer apiClient.Close()
892 892
 
... ...
@@ -908,7 +908,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) {
908 908
 	id := runSleepingContainer(c, "-v", testVol)
909 909
 	cli.WaitRun(c, id)
910 910
 
911
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
911
+	apiClient, err := client.New(client.FromEnv)
912 912
 	assert.NilError(c, err)
913 913
 	defer apiClient.Close()
914 914
 
... ...
@@ -957,7 +957,7 @@ func (s *DockerAPISuite) TestContainerAPIPostContainerStop(c *testing.T) {
957 957
 	containerID := runSleepingContainer(c)
958 958
 	cli.WaitRun(c, containerID)
959 959
 
960
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
960
+	apiClient, err := client.New(client.FromEnv)
961 961
 	assert.NilError(c, err)
962 962
 	defer apiClient.Close()
963 963
 
... ...
@@ -988,7 +988,7 @@ func (s *DockerAPISuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRoot
988 988
 	// Attempt to extract to a symlink in the volume which points to a
989 989
 	// directory outside the volume. This should cause an error because the
990 990
 	// rootfs is read-only.
991
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
991
+	apiClient, err := client.New(client.FromEnv)
992 992
 	assert.NilError(c, err)
993 993
 
994 994
 	_, err = apiClient.CopyToContainer(testutil.GetContext(c), cID, client.CopyToContainerOptions{DestinationPath: "/vol2/symlinkToAbsDir"})
... ...
@@ -999,7 +999,7 @@ func (s *DockerAPISuite) TestPostContainersCreateWithWrongCpusetValues(c *testin
999 999
 	// Not supported on Windows
1000 1000
 	testRequires(c, DaemonIsLinux)
1001 1001
 
1002
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1002
+	apiClient, err := client.New(client.FromEnv)
1003 1003
 	assert.NilError(c, err)
1004 1004
 	defer apiClient.Close()
1005 1005
 
... ...
@@ -1045,7 +1045,7 @@ func (s *DockerAPISuite) TestPostContainersCreateMemorySwappinessHostConfigOmitt
1045 1045
 		Image: "busybox",
1046 1046
 	}
1047 1047
 
1048
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1048
+	apiClient, err := client.New(client.FromEnv)
1049 1049
 	assert.NilError(c, err)
1050 1050
 	defer apiClient.Close()
1051 1051
 
... ...
@@ -1075,7 +1075,7 @@ func (s *DockerAPISuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *
1075 1075
 		OomScoreAdj: 1001,
1076 1076
 	}
1077 1077
 
1078
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1078
+	apiClient, err := client.New(client.FromEnv)
1079 1079
 	assert.NilError(c, err)
1080 1080
 	defer apiClient.Close()
1081 1081
 
... ...
@@ -1108,7 +1108,7 @@ func (s *DockerAPISuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *
1108 1108
 
1109 1109
 // test case for #22210 where an empty container name caused panic.
1110 1110
 func (s *DockerAPISuite) TestContainerAPIDeleteWithEmptyName(c *testing.T) {
1111
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1111
+	apiClient, err := client.New(client.FromEnv)
1112 1112
 	assert.NilError(c, err)
1113 1113
 	defer apiClient.Close()
1114 1114
 
... ...
@@ -1129,7 +1129,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T)
1129 1129
 		NetworkDisabled: true,
1130 1130
 	}
1131 1131
 
1132
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1132
+	apiClient, err := client.New(client.FromEnv)
1133 1133
 	assert.NilError(c, err)
1134 1134
 	defer apiClient.Close()
1135 1135
 
... ...
@@ -1461,7 +1461,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1461 1461
 			},
1462 1462
 		}...)
1463 1463
 	}
1464
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1464
+	apiClient, err := client.New(client.FromEnv)
1465 1465
 	assert.NilError(c, err)
1466 1466
 	defer apiClient.Close()
1467 1467
 
... ...
@@ -1501,7 +1501,7 @@ func (s *DockerAPISuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
1501 1501
 			{Type: "bind", Source: tmpDir, Target: destPath},
1502 1502
 		},
1503 1503
 	}
1504
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1504
+	apiClient, err := client.New(client.FromEnv)
1505 1505
 	assert.NilError(c, err)
1506 1506
 	defer apiClient.Close()
1507 1507
 
... ...
@@ -1747,7 +1747,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
1747 1747
 		},
1748 1748
 	}
1749 1749
 
1750
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
1750
+	apiClient, err := client.New(client.FromEnv)
1751 1751
 	assert.NilError(c, err)
1752 1752
 	defer apiClient.Close()
1753 1753
 
... ...
@@ -60,7 +60,7 @@ func (s *DockerAPISuite) TestExecAPICreateContainerPaused(c *testing.T) {
60 60
 
61 61
 	cli.DockerCmd(c, "pause", name)
62 62
 
63
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
63
+	apiClient, err := client.New(client.FromEnv)
64 64
 	assert.NilError(c, err)
65 65
 	defer apiClient.Close()
66 66
 
... ...
@@ -124,7 +124,7 @@ func (s *DockerAPISuite) TestExecAPIStartWithDetach(c *testing.T) {
124 124
 
125 125
 	ctx := testutil.GetContext(c)
126 126
 
127
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
127
+	apiClient, err := client.New(client.FromEnv)
128 128
 	assert.NilError(c, err)
129 129
 	defer apiClient.Close()
130 130
 
... ...
@@ -37,7 +37,7 @@ func (s *DockerAPISuite) TestAPIImagesSaveAndLoad(c *testing.T) {
37 37
 }
38 38
 
39 39
 func (s *DockerAPISuite) TestAPIImagesDelete(c *testing.T) {
40
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
40
+	apiClient, err := client.New(client.FromEnv)
41 41
 	assert.NilError(c, err)
42 42
 	defer apiClient.Close()
43 43
 
... ...
@@ -109,7 +109,7 @@ func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) {
109 109
 		assert.Assert(c, img.Size != int64(-1))
110 110
 	}
111 111
 
112
-	apiclient, err = client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.24"))
112
+	apiclient, err = client.New(client.FromEnv, client.WithVersion("v1.24"))
113 113
 	assert.NilError(c, err)
114 114
 	defer apiclient.Close()
115 115
 
... ...
@@ -72,7 +72,7 @@ func (s *DockerAPISuite) TestInspectAPIContainerVolumeDriver(c *testing.T) {
72 72
 
73 73
 func (s *DockerAPISuite) TestInspectAPIImageResponse(c *testing.T) {
74 74
 	cli.DockerCmd(c, "tag", "busybox:latest", "busybox:mytag")
75
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
75
+	apiClient, err := client.New(client.FromEnv)
76 76
 	assert.NilError(c, err)
77 77
 	defer apiClient.Close()
78 78
 
... ...
@@ -58,7 +58,7 @@ func (s *DockerAPISuite) TestLogsAPIWithStdout(c *testing.T) {
58 58
 func (s *DockerAPISuite) TestLogsAPINoStdoutNorStderr(c *testing.T) {
59 59
 	const name = "logs_test"
60 60
 	cli.DockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
61
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
61
+	apiClient, err := client.New(client.FromEnv)
62 62
 	assert.NilError(c, err)
63 63
 	defer apiClient.Close()
64 64
 
... ...
@@ -100,7 +100,7 @@ func (s *DockerAPISuite) TestLogsAPIUntilFutureFollow(c *testing.T) {
100 100
 	assert.NilError(c, err)
101 101
 	until := daemonTime(c).Add(untilDur)
102 102
 
103
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
103
+	apiClient, err := client.New(client.FromEnv)
104 104
 	if err != nil {
105 105
 		c.Fatal(err)
106 106
 	}
... ...
@@ -165,7 +165,7 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) {
165 165
 	const name = "logsuntil"
166 166
 	cli.DockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; sleep 1; done")
167 167
 
168
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
168
+	apiClient, err := client.New(client.FromEnv)
169 169
 	if err != nil {
170 170
 		c.Fatal(err)
171 171
 	}
... ...
@@ -202,7 +202,7 @@ func (s *DockerAPISuite) TestLogsAPIUntilDefaultValue(c *testing.T) {
202 202
 	const name = "logsuntildefaultval"
203 203
 	cli.DockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; done")
204 204
 
205
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
205
+	apiClient, err := client.New(client.FromEnv)
206 206
 	if err != nil {
207 207
 		c.Fatal(err)
208 208
 	}
... ...
@@ -180,7 +180,7 @@ func getNetworkStats(t *testing.T, id string) map[string]container.NetworkStats
180 180
 
181 181
 func (s *DockerAPISuite) TestAPIStatsContainerNotFound(c *testing.T) {
182 182
 	testRequires(c, DaemonIsLinux)
183
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
183
+	apiClient, err := client.New(client.FromEnv)
184 184
 	assert.NilError(c, err)
185 185
 	defer func() { _ = apiClient.Close() }()
186 186
 
... ...
@@ -449,7 +449,7 @@ func (s *DockerCLIEventSuite) TestEventsResize(c *testing.T) {
449 449
 	cID := runSleepingContainer(c, "-d", "-t")
450 450
 	cli.WaitRun(c, cID)
451 451
 
452
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
452
+	apiClient, err := client.New(client.FromEnv)
453 453
 	assert.NilError(c, err)
454 454
 	defer apiClient.Close()
455 455
 
... ...
@@ -372,7 +372,7 @@ func (s *DockerCLIExecSuite) TestExecInspectID(c *testing.T) {
372 372
 	}
373 373
 
374 374
 	// But we should still be able to query the execID
375
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
375
+	apiClient, err := client.New(client.FromEnv)
376 376
 	assert.NilError(c, err)
377 377
 	defer apiClient.Close()
378 378
 
... ...
@@ -18,7 +18,7 @@ func (s *DockerCLIInfoSuite) TestInfoSecurityOptions(c *testing.T) {
18 18
 		c.Skip("test requires Seccomp and/or AppArmor")
19 19
 	}
20 20
 
21
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
21
+	apiClient, err := client.New(client.FromEnv)
22 22
 	assert.NilError(c, err)
23 23
 	defer apiClient.Close()
24 24
 	result, err := apiClient.Info(testutil.GetContext(c), client.InfoOptions{})
... ...
@@ -50,7 +50,7 @@ func (s *DockerCLIPluginLogDriverSuite) TestPluginLogDriverInfoList(c *testing.T
50 50
 
51 51
 	cli.DockerCmd(c, "plugin", "install", pluginName)
52 52
 
53
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
53
+	apiClient, err := client.New(client.FromEnv)
54 54
 	assert.NilError(c, err)
55 55
 	defer apiClient.Close()
56 56
 
... ...
@@ -3685,7 +3685,7 @@ func (s *DockerCLIRunSuite) TestRunNamedVolumesFromNotRemoved(c *testing.T) {
3685 3685
 	cid := cli.DockerCmd(c, "run", "-d", "--name=parent", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true").Stdout()
3686 3686
 	cli.DockerCmd(c, "run", "--name=child", "--volumes-from=parent", "busybox", "true")
3687 3687
 
3688
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
3688
+	apiClient, err := client.New(client.FromEnv)
3689 3689
 	assert.NilError(c, err)
3690 3690
 	defer apiClient.Close()
3691 3691
 
... ...
@@ -1558,7 +1558,7 @@ func (s *DockerCLIRunSuite) TestRunWithNanoCPUs(c *testing.T) {
1558 1558
 	out := cli.DockerCmd(c, "run", "--cpus", "0.5", "--name", "test", "busybox", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2)).Combined()
1559 1559
 	assert.Equal(c, strings.TrimSpace(out), "50000\n100000")
1560 1560
 
1561
-	clt, err := client.NewClientWithOpts(client.FromEnv)
1561
+	clt, err := client.New(client.FromEnv)
1562 1562
 	assert.NilError(c, err)
1563 1563
 	res, err := clt.ContainerInspect(testutil.GetContext(c), "test", client.ContainerInspectOptions{})
1564 1564
 	assert.NilError(c, err)
... ...
@@ -264,7 +264,7 @@ func (s *DockerCLIUpdateSuite) TestUpdateWithNanoCPUs(c *testing.T) {
264 264
 	out = cli.DockerCmd(c, "exec", "top", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2)).Combined()
265 265
 	assert.Equal(c, strings.TrimSpace(out), "50000\n100000")
266 266
 
267
-	clt, err := client.NewClientWithOpts(client.FromEnv)
267
+	clt, err := client.New(client.FromEnv)
268 268
 	assert.NilError(c, err)
269 269
 	res, err := clt.ContainerInspect(testutil.GetContext(c), "top", client.ContainerInspectOptions{})
270 270
 	assert.NilError(c, err)
... ...
@@ -577,7 +577,7 @@ func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c
577 577
 	assert.NilError(c, err)
578 578
 
579 579
 	// Mounts is available in API
580
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
580
+	apiClient, err := client.New(client.FromEnv)
581 581
 	assert.NilError(c, err)
582 582
 	defer apiClient.Close()
583 583
 
... ...
@@ -196,7 +196,7 @@ func daemonTime(t *testing.T) time.Time {
196 196
 	if testEnv.IsLocalDaemon() {
197 197
 		return time.Now()
198 198
 	}
199
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
199
+	apiClient, err := client.New(client.FromEnv)
200 200
 	assert.NilError(t, err)
201 201
 	defer apiClient.Close()
202 202
 
... ...
@@ -254,7 +254,7 @@ func waitInspect(name, expr, expected string, timeout time.Duration) error {
254 254
 
255 255
 func getInspectBody(t *testing.T, version, id string) json.RawMessage {
256 256
 	t.Helper()
257
-	apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(version))
257
+	apiClient, err := client.New(client.FromEnv, client.WithVersion(version))
258 258
 	assert.NilError(t, err)
259 259
 	defer apiClient.Close()
260 260
 	inspect, err := apiClient.ContainerInspect(testutil.GetContext(t), id, client.ContainerInspectOptions{})
... ...
@@ -31,7 +31,7 @@ func DaemonIsLinux() bool {
31 31
 }
32 32
 
33 33
 func OnlyDefaultNetworks(ctx context.Context) bool {
34
-	apiClient, err := client.NewClientWithOpts(client.FromEnv)
34
+	apiClient, err := client.New(client.FromEnv)
35 35
 	if err != nil {
36 36
 		return false
37 37
 	}
... ...
@@ -734,7 +734,7 @@ func TestCreateWithMultipleEndpointSettings(t *testing.T) {
734 734
 
735 735
 	for _, tc := range testcases {
736 736
 		t.Run("with API v"+tc.apiVersion, func(t *testing.T) {
737
-			apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(tc.apiVersion))
737
+			apiClient, err := client.New(client.FromEnv, client.WithVersion(tc.apiVersion))
738 738
 			assert.NilError(t, err)
739 739
 
740 740
 			config := container.Config{
... ...
@@ -63,7 +63,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
63 63
 		},
64 64
 	}
65 65
 
66
-	cli, err := client.NewClientWithOpts(client.FromEnv)
66
+	cli, err := client.New(client.FromEnv)
67 67
 	assert.NilError(t, err)
68 68
 	defer cli.Close()
69 69
 
... ...
@@ -524,7 +524,7 @@ func TestContainerBindMountReadOnlyDefault(t *testing.T) {
524 524
 			skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), minDaemonVersion), "requires API v"+minDaemonVersion)
525 525
 
526 526
 			if tc.clientVersion != "" {
527
-				c, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(tc.clientVersion))
527
+				c, err := client.New(client.FromEnv, client.WithVersion(tc.clientVersion))
528 528
 				assert.NilError(t, err, "failed to create client with version v%s", tc.clientVersion)
529 529
 				apiClient = c
530 530
 			}
... ...
@@ -308,7 +308,7 @@ func TestStaticIPOutsideSubpool(t *testing.T) {
308 308
 	d.StartWithBusybox(ctx, t)
309 309
 	defer d.Stop(t)
310 310
 
311
-	apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.43"))
311
+	apiClient, err := client.New(client.FromEnv, client.WithVersion("1.43"))
312 312
 	assert.NilError(t, err)
313 313
 
314 314
 	const netname = "subnet-range"
... ...
@@ -149,7 +149,7 @@ func newTLSAPIClient(host, cacertPath, certPath, keyPath string) (client.APIClie
149 149
 		KeepAlive: 30 * time.Second,
150 150
 		Timeout:   30 * time.Second,
151 151
 	}
152
-	return client.NewClientWithOpts(
152
+	return client.New(
153 153
 		client.WithTLSClientConfig(cacertPath, certPath, keyPath),
154 154
 		client.WithDialContext(dialer.DialContext),
155 155
 		client.WithHost(host))
... ...
@@ -306,7 +306,7 @@ func TestVolumePruneAnonymous(t *testing.T) {
306 306
 	assert.Check(t, is.Equal(len(report.VolumesDeleted), 2))
307 307
 
308 308
 	// Validate that older API versions still have the old behavior of pruning all local volumes
309
-	clientOld, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.41"))
309
+	clientOld, err := client.New(client.FromEnv, client.WithVersion("1.41"))
310 310
 	assert.NilError(t, err)
311 311
 	defer clientOld.Close()
312 312
 	assert.Equal(t, clientOld.ClientVersion(), "1.41")
... ...
@@ -309,7 +309,7 @@ func (d *Daemon) NewClient(extraOpts ...client.Opt) (*client.Client, error) {
309 309
 	}
310 310
 	clientOpts = append(clientOpts, extraOpts...)
311 311
 
312
-	return client.NewClientWithOpts(clientOpts...)
312
+	return client.New(clientOpts...)
313 313
 }
314 314
 
315 315
 // Cleanup cleans the daemon files : exec root (network namespaces, ...), swarmkit files
... ...
@@ -873,7 +873,7 @@ func (d *Daemon) LoadBusybox(ctx context.Context, t testing.TB) {
873 873
 
874 874
 func (d *Daemon) LoadImage(ctx context.Context, t testing.TB, img string) {
875 875
 	t.Helper()
876
-	clientHost, err := client.NewClientWithOpts(client.FromEnv)
876
+	clientHost, err := client.New(client.FromEnv)
877 877
 	assert.NilError(t, err, "[%s] failed to create client", d.id)
878 878
 	defer clientHost.Close()
879 879
 
... ...
@@ -36,7 +36,7 @@ type PlatformDefaults struct {
36 36
 // New creates a new Execution struct
37 37
 // This is configured using the env client (see client.FromEnv)
38 38
 func New(ctx context.Context) (*Execution, error) {
39
-	c, err := client.NewClientWithOpts(client.FromEnv)
39
+	c, err := client.New(client.FromEnv)
40 40
 	if err != nil {
41 41
 		return nil, errors.Wrapf(err, "failed to create client")
42 42
 	}
... ...
@@ -27,7 +27,7 @@ import (
27 27
 func NewAPIClient(t testing.TB, ops ...client.Opt) client.APIClient {
28 28
 	t.Helper()
29 29
 	ops = append([]client.Opt{client.FromEnv}, ops...)
30
-	clt, err := client.NewClientWithOpts(ops...)
30
+	clt, err := client.New(ops...)
31 31
 	assert.NilError(t, err)
32 32
 	return clt
33 33
 }
... ...
@@ -23,7 +23,7 @@ import (
23 23
 )
24 24
 
25 25
 func main() {
26
-	apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
26
+	apiClient, err := client.New(client.FromEnv, client.WithAPIVersionNegotiation())
27 27
 	if err != nil {
28 28
 		panic(err)
29 29
 	}
... ...
@@ -6,7 +6,7 @@ https://docs.docker.com/reference/api/engine/
6 6
 
7 7
 # Usage
8 8
 
9
-You use the library by constructing a client object using [NewClientWithOpts]
9
+You use the library by constructing a client object using [New]
10 10
 and calling methods on it. The client can be configured from environment
11 11
 variables by passing the [FromEnv] option, and the [WithAPIVersionNegotiation]
12 12
 option to allow downgrading the API version used when connecting with an older
... ...
@@ -30,7 +30,7 @@ For example, to list running containers (the equivalent of "docker ps"):
30 30
 		// for configuration (DOCKER_HOST, DOCKER_API_VERSION), and does
31 31
 		// API-version negotiation to allow downgrading the API version
32 32
 		// when connecting with an older daemon version.
33
-		apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
33
+		apiClient, err := client.New(client.FromEnv, client.WithAPIVersionNegotiation())
34 34
 		if err != nil {
35 35
 			log.Fatal(err)
36 36
 		}
... ...
@@ -160,7 +160,14 @@ func CheckRedirect(_ *http.Request, via []*http.Request) error {
160 160
 	return ErrRedirect
161 161
 }
162 162
 
163
-// NewClientWithOpts initializes a new API client with a default HTTPClient, and
163
+// NewClientWithOpts initializes a new API client.
164
+//
165
+// Deprecated: use New. This function will be removed in the next release.
166
+func NewClientWithOpts(ops ...Opt) (*Client, error) {
167
+	return New(ops...)
168
+}
169
+
170
+// New initializes a new API client with a default HTTPClient, and
164 171
 // default API host and version. It also initializes the custom HTTP headers to
165 172
 // add to each request.
166 173
 //
... ...
@@ -170,11 +177,11 @@ func CheckRedirect(_ *http.Request, via []*http.Request) error {
170 170
 // itself with values from environment variables ([FromEnv]), and has automatic
171 171
 // API version negotiation enabled ([WithAPIVersionNegotiation]).
172 172
 //
173
-//	cli, err := client.NewClientWithOpts(
173
+//	cli, err := client.New(
174 174
 //		client.FromEnv,
175 175
 //		client.WithAPIVersionNegotiation(),
176 176
 //	)
177
-func NewClientWithOpts(ops ...Opt) (*Client, error) {
177
+func New(ops ...Opt) (*Client, error) {
178 178
 	hostURL, err := ParseHostURL(DefaultDockerHost)
179 179
 	if err != nil {
180 180
 		return nil, err