From 9bc16bbde085c618d3bddfb633560ab9af83a58d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 4 Mar 2025 14:29:20 +0100 Subject: [PATCH] cli/command: deprecate Cli.NotaryClient This method is a shallow wrapper around trust.GetNotaryRepository, but due to its signature resulted in the trust package, and notary dependencies to become a dependency of the CLI. Consequence of this was that cli-plugins, which need the cli/command package, would also get notary and its dependencies as a dependency. 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 --- cli/command/cli.go | 9 +-------- cli/command/cli_deprecated.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 cli/command/cli_deprecated.go diff --git a/cli/command/cli.go b/cli/command/cli.go index 1452e1a240..dfb4fba69a 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -25,7 +25,6 @@ import ( manifeststore "github.com/docker/cli/cli/manifest/store" registryclient "github.com/docker/cli/cli/registry/client" "github.com/docker/cli/cli/streams" - "github.com/docker/cli/cli/trust" "github.com/docker/cli/cli/version" dopts "github.com/docker/cli/opts" "github.com/docker/docker/api" @@ -36,7 +35,6 @@ import ( "github.com/docker/go-connections/tlsconfig" "github.com/pkg/errors" "github.com/spf13/cobra" - notaryclient "github.com/theupdateframework/notary/client" ) const defaultInitTimeout = 2 * time.Second @@ -56,7 +54,6 @@ type Cli interface { Apply(ops ...CLIOption) error ConfigFile() *configfile.ConfigFile ServerInfo() ServerInfo - NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error) DefaultVersion() string CurrentVersion() string ManifestStore() manifeststore.Store @@ -67,6 +64,7 @@ type Cli interface { CurrentContext() string DockerEndpoint() docker.Endpoint TelemetryClient + DeprecatedNotaryClient } // DockerCli is an instance the docker command line client. @@ -405,11 +403,6 @@ func (cli *DockerCli) initializeFromClient() { cli.client.NegotiateAPIVersionPing(ping) } -// NotaryClient provides a Notary Repository to interact with signed metadata for an image -func (cli *DockerCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error) { - return trust.GetNotaryRepository(cli.In(), cli.Out(), UserAgent(), imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig(), actions...) -} - // ContextStore returns the ContextStore func (cli *DockerCli) ContextStore() store.Store { return cli.contextStore diff --git a/cli/command/cli_deprecated.go b/cli/command/cli_deprecated.go new file mode 100644 index 0000000000..d179f42f22 --- /dev/null +++ b/cli/command/cli_deprecated.go @@ -0,0 +1,18 @@ +package command + +import ( + "github.com/docker/cli/cli/trust" + notaryclient "github.com/theupdateframework/notary/client" +) + +type DeprecatedNotaryClient interface { + // NotaryClient provides a Notary Repository to interact with signed metadata for an image + // + // Deprecated: use [trust.GetNotaryRepository] instead. This method is no longer used and will be removed in the next release. + NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error) +} + +// NotaryClient provides a Notary Repository to interact with signed metadata for an image +func (cli *DockerCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error) { + return trust.GetNotaryRepository(cli.In(), cli.Out(), UserAgent(), imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig(), actions...) +}