From 2d89339b34af9fd710520c4e6b43623b131685d6 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Thu, 24 Oct 2024 13:45:23 +0000 Subject: [PATCH] Add completion for `--storage-opt` Signed-off-by: Harald Albers --- cli/command/container/completion.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/command/container/completion.go b/cli/command/container/completion.go index 91593c5b32..cde6411a42 100644 --- a/cli/command/container/completion.go +++ b/cli/command/container/completion.go @@ -69,6 +69,7 @@ func addCompletions(cmd *cobra.Command, dockerCLI completion.APIClientProvider) _ = cmd.RegisterFlagCompletionFunc("pull", completion.FromList(PullImageAlways, PullImageMissing, PullImageNever)) _ = cmd.RegisterFlagCompletionFunc("restart", completeRestartPolicies) _ = cmd.RegisterFlagCompletionFunc("stop-signal", completeSignals) + _ = cmd.RegisterFlagCompletionFunc("storage-opt", completeStorageOpt) _ = cmd.RegisterFlagCompletionFunc("volumes-from", completion.ContainerNames(dockerCLI, true)) } @@ -114,6 +115,11 @@ func completePid(dockerCLI completion.APIClientProvider) func(cmd *cobra.Command } } +// completeStorageOpt implements shell completion for the `--storage-opt` option of `run` and `create`. +func completeStorageOpt(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { + return []string{"size="}, cobra.ShellCompDirectiveNoSpace +} + // containerNames contacts the API to get names and optionally IDs of containers. // In case of an error, an empty list is returned. func containerNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command, args []string, toComplete string) []string {