From 9a56a5c17d5c5c9d3c5498c3757be9c9ad65fc34 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 5 Jul 2024 14:18:38 +0200 Subject: [PATCH] cli/command/container: provide flag-completion for "docker create" "docker run" and "docker create" are mostly identical, so we can copy the same completion functions, We could possibly create a utility for this (similar to `addFlags()` which configures both commands with the flags they share). I considered combining his with `addFlags()`, but that utility is also used in various tests, in which we don't need this feature, so keeping that for a future exercise. Signed-off-by: Sebastiaan van Stijn --- cli/command/container/create.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 3193ccf20072..208ad6c77bc2 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -77,6 +77,11 @@ func NewCreateCommand(dockerCli command.Cli) *cobra.Command { command.AddPlatformFlag(flags, &options.platform) command.AddTrustVerificationFlags(flags, &options.untrusted, dockerCli.ContentTrustEnabled()) copts = addFlags(flags) + + _ = cmd.RegisterFlagCompletionFunc("env", completion.EnvVarNames) + _ = cmd.RegisterFlagCompletionFunc("env-file", completion.FileNames) + _ = cmd.RegisterFlagCompletionFunc("network", completion.NetworkNames(dockerCli)) + _ = cmd.RegisterFlagCompletionFunc("pull", completion.FromList(PullImageAlways, PullImageMissing, PullImageNever)) return cmd }