Skip to content

Commit

Permalink
push: Improve note message and colors
Browse files Browse the repository at this point in the history
Signed-off-by: Paweł Gronowski <[email protected]>
  • Loading branch information
vvoland committed Jul 9, 2024
1 parent d401994 commit 50edde8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cli/command/image/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func NewPushCommand(dockerCli command.Cli) *cobra.Command {
// on older APIs which don't support it.
flags.StringVar(&opts.platform, "platform", "",
`Push a platform-specific manifest as a single-platform image to the registry.
Image index won't be pushed, meaning that other manifests, including attestations will be lost.
'os[/arch[/variant]]': Explicit platform (eg. linux/amd64)`)
flags.SetAnnotation("platform", "version", []string{"1.46"})

Expand All @@ -82,9 +83,9 @@ func RunPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
}
platform = &p

printNote(dockerCli, `Selecting a single platform will only push one matching image manifest from a multi-platform image index.
This means that any other components attached to the multi-platform image index (like Buildkit attestations) won't be pushed.
If you want to push a whole multi-platform image, make sure all image content is present and remove the --platform flag.
printNote(dockerCli, `Using --platform pushes only the specified platform manifest of a multi-platform image index.
Other components, like attestations, will not be included.
To push the complete multi-platform image, remove the --platform flag.
`)
}

Expand Down Expand Up @@ -181,10 +182,11 @@ func handleAux(dockerCli command.Cli) func(jm jsonmessage.JSONMessage) {
}

func printNote(dockerCli command.Cli, format string, args ...any) {
format = strings.ReplaceAll(format, "`--platform`", aec.Bold.Apply("--platform"))

Check failure on line 185 in cli/command/image/push.go

View workflow job for this annotation

GitHub Actions / codeql

undefined: strings

Check failure on line 185 in cli/command/image/push.go

View workflow job for this annotation

GitHub Actions / codeql

undefined: strings

Check failure on line 185 in cli/command/image/push.go

View workflow job for this annotation

GitHub Actions / codeql

undefined: strings
if dockerCli.Err().IsTerminal() {
_, _ = fmt.Fprint(dockerCli.Err(), aec.WhiteF.Apply(aec.CyanB.Apply("[ NOTE ]"))+" ")
_, _ = fmt.Fprint(dockerCli.Err(), aec.CyanF.Apply("[ NOTE ]")+" ")
} else {
_, _ = fmt.Fprint(dockerCli.Err(), "[ NOTE ] ")
}
_, _ = fmt.Fprintf(dockerCli.Err(), aec.Bold.Apply(format)+"\n", args...)
_, _ = fmt.Fprintf(dockerCli.Err(), aec.Italic.Apply(format)+"\n", args...)
}

0 comments on commit 50edde8

Please sign in to comment.