cli/command/image: notaryClientProvider: don't require arguments
This interface is used in tests to provide a dummy notary client, but none of the tests require any arguments, so let's remove them. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -31,16 +31,16 @@ type target struct {
|
||||
|
||||
// notaryClientProvider is used in tests to provide a dummy notary client.
|
||||
type notaryClientProvider interface {
|
||||
NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
|
||||
NotaryClient() (notaryclient.Repository, error)
|
||||
}
|
||||
|
||||
// newNotaryClient provides a Notary Repository to interact with signed metadata for an image.
|
||||
func newNotaryClient(cli command.Streams, imgRefAndAuth trust.ImageRefAndAuth) (notaryclient.Repository, error) {
|
||||
func newNotaryClient(cli command.Streams, repoInfo *trust.RepositoryInfo, authConfig *registrytypes.AuthConfig) (notaryclient.Repository, error) {
|
||||
if ncp, ok := cli.(notaryClientProvider); ok {
|
||||
// notaryClientProvider is used in tests to provide a dummy notary client.
|
||||
return ncp.NotaryClient(imgRefAndAuth, []string{"pull"})
|
||||
return ncp.NotaryClient()
|
||||
}
|
||||
return trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig(), "pull")
|
||||
return trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), repoInfo, authConfig, "pull")
|
||||
}
|
||||
|
||||
// pushTrustedReference pushes a canonical reference to the trust server.
|
||||
@ -107,7 +107,7 @@ func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.Image
|
||||
}
|
||||
|
||||
func getTrustedPullTargets(cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth) ([]target, error) {
|
||||
notaryRepo, err := newNotaryClient(cli, imgRefAndAuth)
|
||||
notaryRepo, err := newNotaryClient(cli, imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error establishing connection to trust repository: %w", err)
|
||||
}
|
||||
@ -186,7 +186,7 @@ func TrustedReference(ctx context.Context, cli command.Cli, ref reference.NamedT
|
||||
return nil, err
|
||||
}
|
||||
|
||||
notaryRepo, err := newNotaryClient(cli, imgRefAndAuth)
|
||||
notaryRepo, err := newNotaryClient(cli, imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error establishing connection to trust repository: %w", err)
|
||||
}
|
||||
|
||||
@ -52,14 +52,14 @@ type trustKey struct {
|
||||
|
||||
// notaryClientProvider is used in tests to provide a dummy notary client.
|
||||
type notaryClientProvider interface {
|
||||
NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error)
|
||||
NotaryClient() (client.Repository, error)
|
||||
}
|
||||
|
||||
// newNotaryClient provides a Notary Repository to interact with signed metadata for an image.
|
||||
func newNotaryClient(cli command.Streams, imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) {
|
||||
if ncp, ok := cli.(notaryClientProvider); ok {
|
||||
// notaryClientProvider is used in tests to provide a dummy notary client.
|
||||
return ncp.NotaryClient(imgRefAndAuth, actions)
|
||||
return ncp.NotaryClient()
|
||||
}
|
||||
return trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig(), actions...)
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/cli/trust"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/notary"
|
||||
"github.com/theupdateframework/notary/client"
|
||||
@ -48,7 +47,7 @@ func TestTrustInspectCommandRepositoryErrors(t *testing.T) {
|
||||
testCases := []struct {
|
||||
doc string
|
||||
args []string
|
||||
notaryRepository func(trust.ImageRefAndAuth, []string) (client.Repository, error)
|
||||
notaryRepository func() (client.Repository, error)
|
||||
err string
|
||||
golden string
|
||||
}{
|
||||
@ -100,7 +99,7 @@ func TestTrustInspectCommand(t *testing.T) {
|
||||
testCases := []struct {
|
||||
doc string
|
||||
args []string
|
||||
notaryRepository func(trust.ImageRefAndAuth, []string) (client.Repository, error)
|
||||
notaryRepository func() (client.Repository, error)
|
||||
golden string
|
||||
}{
|
||||
{
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/cli/trust"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/notary"
|
||||
"github.com/theupdateframework/notary/client"
|
||||
@ -60,7 +59,7 @@ func TestTrustRevokeCommand(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
doc string
|
||||
notaryRepository func(trust.ImageRefAndAuth, []string) (client.Repository, error)
|
||||
notaryRepository func() (client.Repository, error)
|
||||
args []string
|
||||
expectedErr string
|
||||
expectedMessage string
|
||||
|
||||
Reference in New Issue
Block a user