@@ -13,6 +13,7 @@ import (
1313 "github.com/docker/cli/cli/streams"
1414 "github.com/docker/cli/cli/trust"
1515 "github.com/docker/cli/internal/jsonstream"
16+ "github.com/docker/cli/internal/registry"
1617 "github.com/moby/moby/api/pkg/authconfig"
1718 registrytypes "github.com/moby/moby/api/types/registry"
1819 "github.com/moby/moby/client"
@@ -43,12 +44,18 @@ func newNotaryClient(cli command.Streams, imgRefAndAuth trust.ImageRefAndAuth) (
4344}
4445
4546// pushTrustedReference pushes a canonical reference to the trust server.
46- func pushTrustedReference (ctx context.Context , ioStreams command.Streams , indexInfo * registrytypes.IndexInfo , ref reference.Named , authConfig registrytypes.AuthConfig , in io.Reader ) error {
47+ func pushTrustedReference (ctx context.Context , dockerCLI command.Cli , ref reference.Named , responseBody io.Reader ) error {
48+ // Resolve the Repository name from fqn to RepositoryInfo, and create an
49+ // IndexInfo. Docker Content Trust uses the IndexInfo.Official field to
50+ // select the right domain for Docker Hub's Notary server;
51+ // https://github.com/docker/cli/blob/v28.4.0/cli/trust/trust.go#L65-L79
52+ indexInfo := registry .NewIndexInfo (ref )
4753 repoInfo := & trust.RepositoryInfo {
4854 Name : reference .TrimNamed (ref ),
4955 Index : indexInfo ,
5056 }
51- return trust .PushTrustedReference (ctx , ioStreams , repoInfo , ref , authConfig , in , command .UserAgent ())
57+ authConfig := command .ResolveAuthConfig (dockerCLI .ConfigFile (), indexInfo )
58+ return trust .PushTrustedReference (ctx , dockerCLI , repoInfo , ref , authConfig , responseBody , command .UserAgent ())
5259}
5360
5461// trustedPull handles content trust pulling of an image
0 commit comments