Add completion for `--storage-opt`

Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit 2d89339b34)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Harald Albers 2024-10-24 13:45:23 +00:00 committed by Sebastiaan van Stijn
parent 83f79c3e86
commit 6d087eb91b
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 6 additions and 0 deletions

View File

@ -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 {