From e32d5d56f5fea7cdfb91a317d517cd163c4954d7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 4 Mar 2025 14:49:18 +0100 Subject: [PATCH] cli/command: deprecate Cli.ManifestStore This method is a shallow wrapper around manifeststore.NewStore, 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 --- cli/command/cli.go | 10 +--------- cli/command/cli_deprecated.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index dfb4fba69a..7d15602156 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "os" - "path/filepath" "runtime" "strconv" "strings" @@ -22,7 +21,6 @@ import ( "github.com/docker/cli/cli/context/store" "github.com/docker/cli/cli/debug" cliflags "github.com/docker/cli/cli/flags" - 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/version" @@ -56,7 +54,6 @@ type Cli interface { ServerInfo() ServerInfo DefaultVersion() string CurrentVersion() string - ManifestStore() manifeststore.Store RegistryClient(bool) registryclient.RegistryClient ContentTrustEnabled() bool BuildKitEnabled() (bool, error) @@ -65,6 +62,7 @@ type Cli interface { DockerEndpoint() docker.Endpoint TelemetryClient DeprecatedNotaryClient + DeprecatedManifestClient } // DockerCli is an instance the docker command line client. @@ -229,12 +227,6 @@ func (cli *DockerCli) HooksEnabled() bool { return false } -// ManifestStore returns a store for local manifests -func (*DockerCli) ManifestStore() manifeststore.Store { - // TODO: support override default location from config file - return manifeststore.NewStore(filepath.Join(config.Dir(), "manifests")) -} - // RegistryClient returns a client for communicating with a Docker distribution // registry func (cli *DockerCli) RegistryClient(allowInsecure bool) registryclient.RegistryClient { diff --git a/cli/command/cli_deprecated.go b/cli/command/cli_deprecated.go index d179f42f22..d6e38a607a 100644 --- a/cli/command/cli_deprecated.go +++ b/cli/command/cli_deprecated.go @@ -1,6 +1,10 @@ package command import ( + "path/filepath" + + "github.com/docker/cli/cli/config" + manifeststore "github.com/docker/cli/cli/manifest/store" "github.com/docker/cli/cli/trust" notaryclient "github.com/theupdateframework/notary/client" ) @@ -12,7 +16,21 @@ type DeprecatedNotaryClient interface { NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error) } +type DeprecatedManifestClient interface { + // ManifestStore returns a store for local manifests + // + // Deprecated: use [manifeststore.NewStore] instead. This method is no longer used and will be removed in the next release. + ManifestStore() manifeststore.Store +} + // 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...) } + +// ManifestStore returns a store for local manifests +// +// Deprecated: use [manifeststore.NewStore] instead. This method is no longer used and will be removed in the next release. +func (*DockerCli) ManifestStore() manifeststore.Store { + return manifeststore.NewStore(filepath.Join(config.Dir(), "manifests")) +}