Compare commits

..

15 Commits

Author SHA1 Message Date
Harald Albers 06260e68f3 Handle null completions with a default callback
Credits to thaJeztah

Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 4525fe37b4 Add completion for `--volume-driver`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers db0ed1e216 Add completion for `--cgroupns`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 2915749279 Add completion for `--uts`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 3a2503fa43 Add completion for --log-driver` and --log-opt`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 9a9ae231a9 Add completion for `--security-opt`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 5f7c43e5e6 Add completion for `--detach-keys`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 3292afe6e6 Add completion for `--userns`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 5d709a8d9f Add completion for `--ulimit`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers 2d89339b34 Add completion for `--storage-opt`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers ac7bde6f64 Add completion for `--pid`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:55:59 +00:00
Harald Albers e513454244 Add completion for `--link`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:35:34 +00:00
Harald Albers c555327f0b Add completion for `--ipc`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:35:34 +00:00
Harald Albers b598ec8cdb Add completion for `--attach`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:35:34 +00:00
Harald Albers 761d76750c Share the container completions
Signed-off-by: Harald Albers <github@albersweb.de>
2024-11-08 15:35:34 +00:00
2 changed files with 2 additions and 3 deletions

View File

@ -140,6 +140,7 @@ 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))
}

View File

@ -55,7 +55,6 @@ func TestCompletePid(t *testing.T) {
}
for _, tc := range tests {
tc := tc
t.Run(tc.toComplete, func(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
containerListFunc: tc.containerListFunc,
@ -74,7 +73,7 @@ func TestCompleteRestartPolicies(t *testing.T) {
assert.Check(t, is.DeepEqual(values, expected))
}
func TestCompleteSecurityOpts(t *testing.T) {
func TestCompleteSecurityOpt(t *testing.T) {
tests := []struct {
toComplete string
expectedCompletions []string
@ -119,7 +118,6 @@ func TestCompleteSecurityOpts(t *testing.T) {
}
for _, tc := range tests {
tc := tc
t.Run(tc.toComplete, func(t *testing.T) {
completions, directive := completeSecurityOpt(nil, nil, tc.toComplete)
assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions))