88 "encoding/json"
99 "fmt"
1010 "io"
11- "strings"
1211
1312 "github.com/containerd/platforms"
1413 "github.com/distribution/reference"
@@ -17,6 +16,7 @@ import (
1716 "github.com/docker/cli/cli/command/completion"
1817 "github.com/docker/cli/cli/internal/jsonstream"
1918 "github.com/docker/cli/cli/streams"
19+ "github.com/docker/cli/internal/tui"
2020 "github.com/docker/docker/api/types/auxprogress"
2121 "github.com/docker/docker/api/types/image"
2222 registrytypes "github.com/docker/docker/api/types/registry"
@@ -78,6 +78,7 @@ Image index won't be pushed, meaning that other manifests, including attestation
7878//nolint:gocyclo
7979func RunPush (ctx context.Context , dockerCli command.Cli , opts pushOptions ) error {
8080 var platform * ocispec.Platform
81+ out := tui .NewOutput (dockerCli .Out ())
8182 if opts .platform != "" {
8283 p , err := platforms .Parse (opts .platform )
8384 if err != nil {
@@ -86,7 +87,7 @@ func RunPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
8687 }
8788 platform = & p
8889
89- printNote ( dockerCli , `Using --platform pushes only the specified platform manifest of a multi-platform image index.
90+ out . PrintNote ( `Using --platform pushes only the specified platform manifest of a multi-platform image index.
9091Other components, like attestations, will not be included.
9192To push the complete multi-platform image, remove the --platform flag.
9293` )
@@ -132,8 +133,7 @@ To push the complete multi-platform image, remove the --platform flag.
132133
133134 defer func () {
134135 for _ , note := range notes {
135- fmt .Fprintln (dockerCli .Err (), "" )
136- printNote (dockerCli , note )
136+ out .PrintNote (note )
137137 }
138138 }()
139139
@@ -183,25 +183,3 @@ func handleAux() func(jm jsonstream.JSONMessage) {
183183 }
184184 }
185185}
186-
187- func printNote (dockerCli command.Cli , format string , args ... any ) {
188- if dockerCli .Err ().IsTerminal () {
189- format = strings .ReplaceAll (format , "--platform" , aec .Bold .Apply ("--platform" ))
190- }
191-
192- header := " Info -> "
193- padding := len (header )
194- if dockerCli .Err ().IsTerminal () {
195- padding = len ("i Info > " )
196- header = aec .Bold .Apply (aec .LightCyanB .Apply (aec .BlackF .Apply ("i" )) + " " + aec .LightCyanF .Apply ("Info → " ))
197- }
198-
199- _ , _ = fmt .Fprint (dockerCli .Err (), header )
200- s := fmt .Sprintf (format , args ... )
201- for idx , line := range strings .Split (s , "\n " ) {
202- if idx > 0 {
203- _ , _ = fmt .Fprint (dockerCli .Err (), strings .Repeat (" " , padding ))
204- }
205- _ , _ = fmt .Fprintln (dockerCli .Err (), aec .Italic .Apply (line ))
206- }
207- }
0 commit comments