diff --git a/cli/command/image/push.go b/cli/command/image/push.go index fa028801ae..2d8a838eb2 100644 --- a/cli/command/image/push.go +++ b/cli/command/image/push.go @@ -16,7 +16,6 @@ import ( "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/streams" "github.com/docker/cli/internal/jsonstream" - "github.com/docker/cli/internal/registry" "github.com/docker/cli/internal/tui" "github.com/moby/moby/api/types/auxprogress" "github.com/moby/moby/client" @@ -129,10 +128,7 @@ To push the complete multi-platform image, remove the --platform flag. }() if !opts.untrusted { - // Resolve the Repository name from fqn to RepositoryInfo - indexInfo := registry.NewIndexInfo(ref) - authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), indexInfo) - return pushTrustedReference(ctx, dockerCli, indexInfo, ref, authConfig, responseBody) + return pushTrustedReference(ctx, dockerCli, ref, responseBody) } if opts.quiet { diff --git a/cli/command/image/trust.go b/cli/command/image/trust.go index 516ece1cf5..38005117c6 100644 --- a/cli/command/image/trust.go +++ b/cli/command/image/trust.go @@ -12,6 +12,7 @@ import ( "github.com/docker/cli/cli/streams" "github.com/docker/cli/cli/trust" "github.com/docker/cli/internal/jsonstream" + "github.com/docker/cli/internal/registry" "github.com/moby/moby/api/pkg/authconfig" registrytypes "github.com/moby/moby/api/types/registry" "github.com/moby/moby/client" @@ -43,12 +44,15 @@ func newNotaryClient(cli command.Streams, imgRefAndAuth trust.ImageRefAndAuth) ( } // pushTrustedReference pushes a canonical reference to the trust server. -func pushTrustedReference(ctx context.Context, ioStreams command.Streams, indexInfo *registrytypes.IndexInfo, ref reference.Named, authConfig registrytypes.AuthConfig, in io.Reader) error { +func pushTrustedReference(ctx context.Context, dockerCLI command.Cli, ref reference.Named, responseBody io.Reader) error { + // Resolve the Repository name from fqn to RepositoryInfo + indexInfo := registry.NewIndexInfo(ref) repoInfo := &trust.RepositoryInfo{ Name: reference.TrimNamed(ref), Index: indexInfo, } - return trust.PushTrustedReference(ctx, ioStreams, repoInfo, ref, authConfig, in, command.UserAgent()) + authConfig := command.ResolveAuthConfig(dockerCLI.ConfigFile(), indexInfo) + return trust.PushTrustedReference(ctx, dockerCLI, repoInfo, ref, authConfig, responseBody, command.UserAgent()) } // trustedPull handles content trust pulling of an image