Skip to content

Commit 6b9968e

Browse files
committed
client: deprecate NewClient properly
The 'Deprecated:' line in NewClient's doc comment was not in a new paragraph, so GoDoc, linters, and IDEs were unaware that it was deprecated. The package documentation also continued to reference NewClient. Update the doc comments to finish documenting that NewClient is deprecated. Signed-off-by: Cory Snider <[email protected]>
1 parent d94d51d commit 6b9968e

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

client/client.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ https://docs.docker.com/engine/api/
66
77
# Usage
88
9-
You use the library by creating a client object and calling methods on it. The
10-
client can be created either from environment variables with NewClientWithOpts(client.FromEnv),
11-
or configured manually with NewClient().
9+
You use the library by constructing a client object using [NewClientWithOpts]
10+
and calling methods on it. The client can be configured from environment
11+
variables by passing the [FromEnv] option, or configured manually by passing any
12+
of the other available [Opts].
1213
1314
For example, to list running containers (the equivalent of "docker ps"):
1415

client/client_deprecated.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ import "net/http"
99
// It won't send any version information if the version number is empty. It is
1010
// highly recommended that you set a version or your client may break if the
1111
// server is upgraded.
12-
// Deprecated: use NewClientWithOpts
12+
//
13+
// Deprecated: use [NewClientWithOpts] passing the [WithHost], [WithVersion],
14+
// [WithHTTPClient] and [WithHTTPHeaders] options. We recommend enabling API
15+
// version negotiation by passing the [WithAPIVersionNegotiation] option instead
16+
// of WithVersion.
1317
func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) {
1418
return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders))
1519
}
1620

1721
// NewEnvClient initializes a new API client based on environment variables.
1822
// See FromEnv for a list of support environment variables.
1923
//
20-
// Deprecated: use NewClientWithOpts(FromEnv)
24+
// Deprecated: use [NewClientWithOpts] passing the [FromEnv] option.
2125
func NewEnvClient() (*Client, error) {
2226
return NewClientWithOpts(FromEnv)
2327
}

0 commit comments

Comments
 (0)