mirror of https://github.com/docker/cli.git
cli/command/image: add shell completion for --platform flags
With this patch, completion is provided for `--platform` flags: docker pull --platform<TAB> linux linux/amd64 linux/arm/v5 linux/arm/v7 linux/arm64/v8 linux/riscv64 wasip1 windows linux/386 linux/arm linux/arm/v6 linux/arm64 linux/ppc64le linux/s390x wasip1/wasm windows/amd64 Note that `docker buildx build` (with BuildKit) does not yet provide completion; it's provided through buildx, and uses a different format (accepting multiple comma-separated platforms). Interestingly, tab-completion for `docker build` currently uses completion for non-buildkit, and has some other issues that may have to be looked into. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
8c7f713db6
commit
d42cf96e15
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/docker/cli-docs-tool/annotation"
|
"github.com/docker/cli-docs-tool/annotation"
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/cli/cli/command/image/build"
|
"github.com/docker/cli/cli/command/image/build"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api"
|
"github.com/docker/docker/api"
|
||||||
|
@ -159,6 +160,8 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
flags.SetAnnotation("squash", "experimental", nil)
|
flags.SetAnnotation("squash", "experimental", nil)
|
||||||
flags.SetAnnotation("squash", "version", []string{"1.25"})
|
flags.SetAnnotation("squash", "version", []string{"1.25"})
|
||||||
|
|
||||||
|
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/docker/cli/cli/command/completion"
|
||||||
dockeropts "github.com/docker/cli/opts"
|
dockeropts "github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
|
@ -47,6 +48,7 @@ func NewImportCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
flags.VarP(&options.changes, "change", "c", "Apply Dockerfile instruction to the created image")
|
flags.VarP(&options.changes, "change", "c", "Apply Dockerfile instruction to the created image")
|
||||||
flags.StringVarP(&options.message, "message", "m", "", "Set commit message for imported image")
|
flags.StringVarP(&options.message, "message", "m", "", "Set commit message for imported image")
|
||||||
command.AddPlatformFlag(flags, &options.platform)
|
command.AddPlatformFlag(flags, &options.platform)
|
||||||
|
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ func NewPullCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
command.AddPlatformFlag(flags, &opts.platform)
|
command.AddPlatformFlag(flags, &opts.platform)
|
||||||
command.AddTrustVerificationFlags(flags, &opts.untrusted, dockerCli.ContentTrustEnabled())
|
command.AddTrustVerificationFlags(flags, &opts.untrusted, dockerCli.ContentTrustEnabled())
|
||||||
|
|
||||||
|
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,8 @@ Image index won't be pushed, meaning that other manifests, including attestation
|
||||||
'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"})
|
||||||
|
|
||||||
|
_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue