Skip to content

Commit 11e017b

Browse files
committed
image/tree: Chips to represent "in use"/"attested"
Signed-off-by: Paweł Gronowski <[email protected]>
1 parent ad54f75 commit 11e017b

File tree

8 files changed

+391
-99
lines changed

8 files changed

+391
-99
lines changed

cli/command/image/push.go

+3-26
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
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"
@@ -86,7 +86,7 @@ func RunPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
8686
}
8787
platform = &p
8888

89-
printNote(dockerCli, `Using --platform pushes only the specified platform manifest of a multi-platform image index.
89+
tui.PrintNote(dockerCli.Err(), `Using --platform pushes only the specified platform manifest of a multi-platform image index.
9090
Other components, like attestations, will not be included.
9191
To push the complete multi-platform image, remove the --platform flag.
9292
`)
@@ -132,8 +132,7 @@ To push the complete multi-platform image, remove the --platform flag.
132132

133133
defer func() {
134134
for _, note := range notes {
135-
fmt.Fprintln(dockerCli.Err(), "")
136-
printNote(dockerCli, note)
135+
tui.PrintNote(dockerCli.Out(), note)
137136
}
138137
}()
139138

@@ -183,25 +182,3 @@ func handleAux() func(jm jsonstream.JSONMessage) {
183182
}
184183
}
185184
}
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

Comments
 (0)