From e512522843da83726ed670f3eb106db19e8e2620 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 30 Oct 2026 11:39:24 +0100 Subject: [PATCH] manifest: annotate: add shell-completion for --os and --arch With this patch; docker manifest annotate --os aix darwin freebsd illumos js nacl openbsd solaris zos android dragonfly hurd ios linux netbsd plan9 windows docker manifest annotate --arch 386 arm armbe mips64 mips64p32le ppc64 riscv64 sparc amd64 arm64 loong64 mips64le mipsle ppc64le s390 sparc64 amd64p32 arm64be mips mips64p32 ppc riscv s390x wasm Signed-off-by: Sebastiaan van Stijn --- cli/command/manifest/annotate.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cli/command/manifest/annotate.go b/cli/command/manifest/annotate.go index fd8102bfc088..84962200b99f 100644 --- a/cli/command/manifest/annotate.go +++ b/cli/command/manifest/annotate.go @@ -13,6 +13,7 @@ import ( "github.com/containerd/platforms" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" + "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/manifest/store" "github.com/docker/cli/internal/registryclient" @@ -21,6 +22,23 @@ import ( "github.com/spf13/cobra" ) +var ( + // similar to https://github.com/containerd/platforms/blob/v1.0.0-rc.5/database.go#L29-L38 + knownOSes = []string{ + "aix", "android", "darwin", "dragonfly", "freebsd", "hurd", "illumos", + "ios", "js", "linux", "nacl", "netbsd", "openbsd", "plan9", "solaris", + "windows", "zos", + } + + // similar to https://github.com/containerd/platforms/blob/v1.0.0-rc.5/database.go#L51-L60 + knownArches = []string{ + "386", "amd64", "amd64p32", "arm", "armbe", "arm64", "arm64be", "ppc64", + "ppc64le", "loong64", "mips", "mipsle", "mips64", "mips64le", "mips64p32", + "mips64p32le", "ppc", "riscv", "riscv64", "s390", "s390x", "sparc", + "sparc64", "wasm", + } +) + type annotateOptions struct { target string // the target manifest list name (also transaction ID) image string // the manifest to annotate within the list @@ -98,6 +116,8 @@ func newAnnotateCommand(dockerCLI command.Cli) *cobra.Command { flags.StringSliceVar(&opts.osFeatures, "os-features", []string{}, "Set operating system feature") flags.StringVar(&opts.variant, "variant", "", "Set architecture variant") + _ = cmd.RegisterFlagCompletionFunc("os", completion.FromList(knownOSes...)) + _ = cmd.RegisterFlagCompletionFunc("arch", completion.FromList(knownArches...)) return cmd }