Skip to content

Commit 2997c0d

Browse files
committed
client: deprecate CommonAPIClient interface
The CommonAPIClient was used to define all the stable interfaces, and combined with the experimental ones through APIClient. In theory, this would allow someone to make sure they only depended on non-experimental methods or to implement an alternative client that only implements the stable methods. While there are users currently using this interface, all those uses depend on the actual client implementation, not a custom one, so they should be able to switch to use APIClient instead. In the meantime, start with deprecating, but keeping the interface the same for now, scheduling it to become an alias, and removed in a future release. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3725998 commit 2997c0d

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import (
66
"github.com/docker/docker/api/types/checkpoint"
77
)
88

9-
type apiClientExperimental interface {
10-
CheckpointAPIClient
11-
}
12-
13-
// CheckpointAPIClient defines API client methods for the checkpoints
9+
// CheckpointAPIClient defines API client methods for the checkpoints.
10+
//
11+
// Experimental: checkpoint and restore is still an experimental feature,
12+
// and only available if the daemon is running with experimental features
13+
// enabled.
1414
type CheckpointAPIClient interface {
1515
CheckpointCreate(ctx context.Context, container string, options checkpoint.CreateOptions) error
1616
CheckpointDelete(ctx context.Context, container string, options checkpoint.DeleteOptions) error

client/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ const DummyHost = "api.moby.localhost"
9999
// recent version before negotiation was introduced.
100100
const fallbackAPIVersion = "1.24"
101101

102+
// Ensure that Client always implements APIClient.
103+
var _ APIClient = &Client{}
104+
102105
// Client is the API client that performs all operations
103106
// against a docker server.
104107
type Client struct {
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ import (
2020
)
2121

2222
// CommonAPIClient is the common methods between stable and experimental versions of APIClient.
23-
type CommonAPIClient interface {
23+
//
24+
// Deprecated: use [APIClient] instead. This type will be an alias for [APIClient] in the next release, and removed after.
25+
type CommonAPIClient = stableAPIClient
26+
27+
// APIClient is an interface that clients that talk with a docker server must implement.
28+
type APIClient interface {
29+
stableAPIClient
30+
CheckpointAPIClient // CheckpointAPIClient is still experimental.
31+
}
32+
33+
type stableAPIClient interface {
2434
ConfigAPIClient
2535
ContainerAPIClient
2636
DistributionAPIClient

client/interface_stable.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)