From db0ed1e21650d504d1892795ffd0c58f38ba3f3e Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Wed, 30 Oct 2024 15:55:19 +0000 Subject: [PATCH] Add completion for `--cgroupns` 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 8cc7b71de3..840c6de86e 100644 --- a/cli/command/container/completion.go +++ b/cli/command/container/completion.go @@ -118,6 +118,7 @@ func addCompletions(cmd *cobra.Command, dockerCLI completion.APIClientProvider) _ = cmd.RegisterFlagCompletionFunc("attach", completion.FromList("stderr", "stdin", "stdout")) _ = cmd.RegisterFlagCompletionFunc("cap-add", completeLinuxCapabilityNames) _ = cmd.RegisterFlagCompletionFunc("cap-drop", completeLinuxCapabilityNames) + _ = cmd.RegisterFlagCompletionFunc("cgroupns", completeCgroupns()) _ = cmd.RegisterFlagCompletionFunc("env", completion.EnvVarNames) _ = cmd.RegisterFlagCompletionFunc("env-file", completion.FileNames) _ = cmd.RegisterFlagCompletionFunc("ipc", completeIpc(dockerCLI)) @@ -138,6 +139,11 @@ func addCompletions(cmd *cobra.Command, dockerCLI completion.APIClientProvider) _ = cmd.RegisterFlagCompletionFunc("volumes-from", completion.ContainerNames(dockerCLI, true)) } +// completeCgroupns implements shell completion for the `--cgroupns` option of `run` and `create`. +func completeCgroupns() completion.ValidArgsFn { + return completion.FromList(string(container.CgroupnsModeHost), string(container.CgroupnsModePrivate)) +} + // completeDetachKeys implements shell completion for the `--detach-keys` option of `run` and `create`. func completeDetachKeys(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { return []string{"ctrl-"}, cobra.ShellCompDirectiveNoSpace