Skip to content

Commit 9bc16bb

Browse files
committed
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 <github@gone.nl>
1 parent 2793731 commit 9bc16bb

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

cli/command/cli.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
manifeststore "github.com/docker/cli/cli/manifest/store"
2626
registryclient "github.com/docker/cli/cli/registry/client"
2727
"github.com/docker/cli/cli/streams"
28-
"github.com/docker/cli/cli/trust"
2928
"github.com/docker/cli/cli/version"
3029
dopts "github.com/docker/cli/opts"
3130
"github.com/docker/docker/api"
@@ -36,7 +35,6 @@ import (
3635
"github.com/docker/go-connections/tlsconfig"
3736
"github.com/pkg/errors"
3837
"github.com/spf13/cobra"
39-
notaryclient "github.com/theupdateframework/notary/client"
4038
)
4139

4240
const defaultInitTimeout = 2 * time.Second
@@ -56,7 +54,6 @@ type Cli interface {
5654
Apply(ops ...CLIOption) error
5755
ConfigFile() *configfile.ConfigFile
5856
ServerInfo() ServerInfo
59-
NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
6057
DefaultVersion() string
6158
CurrentVersion() string
6259
ManifestStore() manifeststore.Store
@@ -67,6 +64,7 @@ type Cli interface {
6764
CurrentContext() string
6865
DockerEndpoint() docker.Endpoint
6966
TelemetryClient
67+
DeprecatedNotaryClient
7068
}
7169

7270
// DockerCli is an instance the docker command line client.
@@ -405,11 +403,6 @@ func (cli *DockerCli) initializeFromClient() {
405403
cli.client.NegotiateAPIVersionPing(ping)
406404
}
407405

408-
// NotaryClient provides a Notary Repository to interact with signed metadata for an image
409-
func (cli *DockerCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error) {
410-
return trust.GetNotaryRepository(cli.In(), cli.Out(), UserAgent(), imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig(), actions...)
411-
}
412-
413406
// ContextStore returns the ContextStore
414407
func (cli *DockerCli) ContextStore() store.Store {
415408
return cli.contextStore

cli/command/cli_deprecated.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package command
2+
3+
import (
4+
"github.com/docker/cli/cli/trust"
5+
notaryclient "github.com/theupdateframework/notary/client"
6+
)
7+
8+
type DeprecatedNotaryClient interface {
9+
// NotaryClient provides a Notary Repository to interact with signed metadata for an image
10+
//
11+
// Deprecated: use [trust.GetNotaryRepository] instead. This method is no longer used and will be removed in the next release.
12+
NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
13+
}
14+
15+
// NotaryClient provides a Notary Repository to interact with signed metadata for an image
16+
func (cli *DockerCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error) {
17+
return trust.GetNotaryRepository(cli.In(), cli.Out(), UserAgent(), imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig(), actions...)
18+
}

0 commit comments

Comments
 (0)