mirror of https://github.com/docker/cli.git
push: Improve note message and colors
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
d40199440d
commit
6c04adc05e
|
@ -8,6 +8,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/containerd/platforms"
|
"github.com/containerd/platforms"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
|
@ -63,6 +64,7 @@ func NewPushCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
// on older APIs which don't support it.
|
// on older APIs which don't support it.
|
||||||
flags.StringVar(&opts.platform, "platform", "",
|
flags.StringVar(&opts.platform, "platform", "",
|
||||||
`Push a platform-specific manifest as a single-platform image to the registry.
|
`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 won't be preserved.
|
||||||
'os[/arch[/variant]]': Explicit platform (eg. linux/amd64)`)
|
'os[/arch[/variant]]': Explicit platform (eg. linux/amd64)`)
|
||||||
flags.SetAnnotation("platform", "version", []string{"1.46"})
|
flags.SetAnnotation("platform", "version", []string{"1.46"})
|
||||||
|
|
||||||
|
@ -82,9 +84,9 @@ func RunPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
|
||||||
}
|
}
|
||||||
platform = &p
|
platform = &p
|
||||||
|
|
||||||
printNote(dockerCli, `Selecting a single platform will only push one matching image manifest from a multi-platform image index.
|
printNote(dockerCli, `Using --platform pushes only the specified platform manifest of 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.
|
Other components, like attestations, will not be included.
|
||||||
If you want to push a whole multi-platform image, make sure all image content is present and remove the --platform flag.
|
To push the complete multi-platform image, remove the --platform flag.
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,9 +184,22 @@ func handleAux(dockerCli command.Cli) func(jm jsonmessage.JSONMessage) {
|
||||||
|
|
||||||
func printNote(dockerCli command.Cli, format string, args ...any) {
|
func printNote(dockerCli command.Cli, format string, args ...any) {
|
||||||
if dockerCli.Err().IsTerminal() {
|
if dockerCli.Err().IsTerminal() {
|
||||||
_, _ = fmt.Fprint(dockerCli.Err(), aec.WhiteF.Apply(aec.CyanB.Apply("[ NOTE ]"))+" ")
|
format = strings.ReplaceAll(format, "--platform", aec.Bold.Apply("--platform"))
|
||||||
} else {
|
}
|
||||||
_, _ = fmt.Fprint(dockerCli.Err(), "[ NOTE ] ")
|
|
||||||
|
header := " Info -> "
|
||||||
|
padding := len(header)
|
||||||
|
if dockerCli.Err().IsTerminal() {
|
||||||
|
padding = len("i Info > ")
|
||||||
|
header = aec.Bold.Apply(aec.LightCyanB.Apply(aec.BlackF.Apply("i")) + " " + aec.LightCyanF.Apply("Info → "))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _ = fmt.Fprint(dockerCli.Err(), header)
|
||||||
|
s := fmt.Sprintf(format, args...)
|
||||||
|
for idx, line := range strings.Split(s, "\n") {
|
||||||
|
if idx > 0 {
|
||||||
|
_, _ = fmt.Fprint(dockerCli.Err(), strings.Repeat(" ", padding))
|
||||||
|
}
|
||||||
|
_, _ = fmt.Fprintln(dockerCli.Err(), aec.Italic.Apply(line))
|
||||||
}
|
}
|
||||||
_, _ = fmt.Fprintf(dockerCli.Err(), aec.Bold.Apply(format)+"\n", args...)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,12 @@ Upload an image to a registry
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:---------------------------------------------|:---------|:--------|:--------------------------------------------------------------------------------------------------------------------------------------------|
|
|:---------------------------------------------|:---------|:--------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| [`-a`](#all-tags), [`--all-tags`](#all-tags) | `bool` | | Push all tags of an image to the repository |
|
| [`-a`](#all-tags), [`--all-tags`](#all-tags) | `bool` | | Push all tags of an image to the repository |
|
||||||
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
|
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
|
||||||
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
|
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>Image index won't be pushed, meaning that other manifests, including attestations won't be preserved.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
|
||||||
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
|
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -9,12 +9,12 @@ Upload an image to a registry
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:--------------------------|:---------|:--------|:--------------------------------------------------------------------------------------------------------------------------------------------|
|
|:--------------------------|:---------|:--------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `-a`, `--all-tags` | `bool` | | Push all tags of an image to the repository |
|
| `-a`, `--all-tags` | `bool` | | Push all tags of an image to the repository |
|
||||||
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
|
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
|
||||||
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
|
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>Image index won't be pushed, meaning that other manifests, including attestations won't be preserved.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
|
||||||
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
|
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
Loading…
Reference in New Issue