@@ -10,12 +10,12 @@ import (
1010
1111 "github.com/distribution/reference"
1212 "github.com/docker/cli/cli/command"
13+ "github.com/docker/cli/cli/internal/jsonstream"
1314 "github.com/docker/cli/cli/streams"
1415 "github.com/docker/cli/cli/trust"
1516 "github.com/docker/docker/api/types"
1617 "github.com/docker/docker/api/types/image"
1718 registrytypes "github.com/docker/docker/api/types/registry"
18- "github.com/docker/docker/pkg/jsonmessage"
1919 "github.com/docker/docker/registry"
2020 "github.com/opencontainers/go-digest"
2121 "github.com/pkg/errors"
@@ -39,20 +39,20 @@ func TrustedPush(ctx context.Context, cli command.Cli, repoInfo *registry.Reposi
3939
4040 defer responseBody .Close ()
4141
42- return PushTrustedReference (cli , repoInfo , ref , authConfig , responseBody )
42+ return PushTrustedReference (ctx , cli , repoInfo , ref , authConfig , responseBody )
4343}
4444
4545// PushTrustedReference pushes a canonical reference to the trust server.
4646//
4747//nolint:gocyclo
48- func PushTrustedReference (ioStreams command.Streams , repoInfo * registry.RepositoryInfo , ref reference.Named , authConfig registrytypes.AuthConfig , in io.Reader ) error {
48+ func PushTrustedReference (ctx context. Context , ioStreams command.Streams , repoInfo * registry.RepositoryInfo , ref reference.Named , authConfig registrytypes.AuthConfig , in io.Reader ) error {
4949 // If it is a trusted push we would like to find the target entry which match the
5050 // tag provided in the function and then do an AddTarget later.
5151 target := & client.Target {}
5252 // Count the times of calling for handleTarget,
5353 // if it is called more that once, that should be considered an error in a trusted push.
5454 cnt := 0
55- handleTarget := func (msg jsonmessage .JSONMessage ) {
55+ handleTarget := func (msg jsonstream .JSONMessage ) {
5656 cnt ++
5757 if cnt > 1 {
5858 // handleTarget should only be called once. This will be treated as an error.
@@ -84,14 +84,14 @@ func PushTrustedReference(ioStreams command.Streams, repoInfo *registry.Reposito
8484 default :
8585 // We want trust signatures to always take an explicit tag,
8686 // otherwise it will act as an untrusted push.
87- if err := jsonmessage . DisplayJSONMessagesToStream ( in , ioStreams .Out (), nil ); err != nil {
87+ if err := jsonstream . Display ( ctx , in , ioStreams .Out ()); err != nil {
8888 return err
8989 }
9090 fmt .Fprintln (ioStreams .Err (), "No tag specified, skipping trust metadata push" )
9191 return nil
9292 }
9393
94- if err := jsonmessage . DisplayJSONMessagesToStream ( in , ioStreams .Out (), handleTarget ); err != nil {
94+ if err := jsonstream . Display ( ctx , in , ioStreams .Out (), jsonstream . WithAuxCallback ( handleTarget ) ); err != nil {
9595 return err
9696 }
9797
@@ -283,7 +283,7 @@ func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth tru
283283 if opts .quiet {
284284 out = streams .NewOut (io .Discard )
285285 }
286- return jsonmessage . DisplayJSONMessagesToStream ( responseBody , out , nil )
286+ return jsonstream . Display ( ctx , responseBody , out )
287287}
288288
289289// TrustedReference returns the canonical trusted reference for an image reference
0 commit comments