Skip to content

Commit 8ad0721

Browse files
committed
cli/command: deprecate Cli.RegistryClient
This method was a shallow wrapper around registryclient.NewRegistryClient but due to its signature resulted in various dependencies becoming a dependency of the "command" package. Consequence of this was that cli-plugins, which need the cli/command package, would also get those dependencies. It is no longer used in our code, which constructs the client in packages that need it, so we can deprecate this method. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent e32d5d5 commit 8ad0721

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

cli/command/cli.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ import (
2121
"github.com/docker/cli/cli/context/store"
2222
"github.com/docker/cli/cli/debug"
2323
cliflags "github.com/docker/cli/cli/flags"
24-
registryclient "github.com/docker/cli/cli/registry/client"
2524
"github.com/docker/cli/cli/streams"
2625
"github.com/docker/cli/cli/version"
2726
dopts "github.com/docker/cli/opts"
2827
"github.com/docker/docker/api"
2928
"github.com/docker/docker/api/types"
30-
"github.com/docker/docker/api/types/registry"
3129
"github.com/docker/docker/api/types/swarm"
3230
"github.com/docker/docker/client"
3331
"github.com/docker/go-connections/tlsconfig"
@@ -54,7 +52,6 @@ type Cli interface {
5452
ServerInfo() ServerInfo
5553
DefaultVersion() string
5654
CurrentVersion() string
57-
RegistryClient(bool) registryclient.RegistryClient
5855
ContentTrustEnabled() bool
5956
BuildKitEnabled() (bool, error)
6057
ContextStore() store.Store
@@ -227,15 +224,6 @@ func (cli *DockerCli) HooksEnabled() bool {
227224
return false
228225
}
229226

230-
// RegistryClient returns a client for communicating with a Docker distribution
231-
// registry
232-
func (cli *DockerCli) RegistryClient(allowInsecure bool) registryclient.RegistryClient {
233-
resolver := func(ctx context.Context, index *registry.IndexInfo) registry.AuthConfig {
234-
return ResolveAuthConfig(cli.ConfigFile(), index)
235-
}
236-
return registryclient.NewRegistryClient(resolver, UserAgent(), allowInsecure)
237-
}
238-
239227
// WithInitializeClient is passed to DockerCli.Initialize by callers who wish to set a particular API Client for use by the CLI.
240228
func WithInitializeClient(makeClient func(dockerCli *DockerCli) (client.APIClient, error)) CLIOption {
241229
return func(dockerCli *DockerCli) error {

cli/command/cli_deprecated.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package command
22

33
import (
4+
"context"
45
"path/filepath"
56

67
"github.com/docker/cli/cli/config"
78
manifeststore "github.com/docker/cli/cli/manifest/store"
9+
registryclient "github.com/docker/cli/cli/registry/client"
810
"github.com/docker/cli/cli/trust"
11+
"github.com/docker/docker/api/types/registry"
912
notaryclient "github.com/theupdateframework/notary/client"
1013
)
1114

@@ -21,6 +24,12 @@ type DeprecatedManifestClient interface {
2124
//
2225
// Deprecated: use [manifeststore.NewStore] instead. This method is no longer used and will be removed in the next release.
2326
ManifestStore() manifeststore.Store
27+
28+
// RegistryClient returns a client for communicating with a Docker distribution
29+
// registry.
30+
//
31+
// Deprecated: use [registryclient.NewRegistryClient]. This method is no longer used and will be removed in the next release.
32+
RegistryClient(bool) registryclient.RegistryClient
2433
}
2534

2635
// NotaryClient provides a Notary Repository to interact with signed metadata for an image
@@ -34,3 +43,14 @@ func (cli *DockerCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions
3443
func (*DockerCli) ManifestStore() manifeststore.Store {
3544
return manifeststore.NewStore(filepath.Join(config.Dir(), "manifests"))
3645
}
46+
47+
// RegistryClient returns a client for communicating with a Docker distribution
48+
// registry
49+
//
50+
// Deprecated: use [registryclient.NewRegistryClient]. This method is no longer used and will be removed in the next release.
51+
func (cli *DockerCli) RegistryClient(allowInsecure bool) registryclient.RegistryClient {
52+
resolver := func(ctx context.Context, index *registry.IndexInfo) registry.AuthConfig {
53+
return ResolveAuthConfig(cli.ConfigFile(), index)
54+
}
55+
return registryclient.NewRegistryClient(resolver, UserAgent(), allowInsecure)
56+
}

0 commit comments

Comments
 (0)