Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-08-26 17:43:44 +02:00
parent c85961b15d
commit 6e8a0d3b6e
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 7 additions and 7 deletions

View File

@ -16,7 +16,6 @@ import (
"github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/cli/streams" "github.com/docker/cli/cli/streams"
"github.com/docker/cli/internal/jsonstream" "github.com/docker/cli/internal/jsonstream"
"github.com/docker/cli/internal/registry"
"github.com/docker/cli/internal/tui" "github.com/docker/cli/internal/tui"
"github.com/moby/moby/api/types/auxprogress" "github.com/moby/moby/api/types/auxprogress"
"github.com/moby/moby/client" "github.com/moby/moby/client"
@ -129,10 +128,7 @@ To push the complete multi-platform image, remove the --platform flag.
}() }()
if !opts.untrusted { if !opts.untrusted {
// Resolve the Repository name from fqn to RepositoryInfo return pushTrustedReference(ctx, dockerCli, ref, responseBody)
indexInfo := registry.NewIndexInfo(ref)
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), indexInfo)
return pushTrustedReference(ctx, dockerCli, indexInfo, ref, authConfig, responseBody)
} }
if opts.quiet { if opts.quiet {

View File

@ -12,6 +12,7 @@ import (
"github.com/docker/cli/cli/streams" "github.com/docker/cli/cli/streams"
"github.com/docker/cli/cli/trust" "github.com/docker/cli/cli/trust"
"github.com/docker/cli/internal/jsonstream" "github.com/docker/cli/internal/jsonstream"
"github.com/docker/cli/internal/registry"
"github.com/moby/moby/api/pkg/authconfig" "github.com/moby/moby/api/pkg/authconfig"
registrytypes "github.com/moby/moby/api/types/registry" registrytypes "github.com/moby/moby/api/types/registry"
"github.com/moby/moby/client" "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. // 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{ repoInfo := &trust.RepositoryInfo{
Name: reference.TrimNamed(ref), Name: reference.TrimNamed(ref),
Index: indexInfo, 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 // trustedPull handles content trust pulling of an image