completeSecurityOpt implements shell completion for the `--security-opt` option of `run` and `create`. The completion is partly composite.
(_ *cobra.Command, _ []string, toComplete string)
| 252 | // completeSecurityOpt implements shell completion for the `--security-opt` option of `run` and `create`. |
| 253 | // The completion is partly composite. |
| 254 | func completeSecurityOpt(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 255 | if len(toComplete) > 0 && strings.HasPrefix("apparmor=", toComplete) { //nolint:gocritic // not swapped, matches partly typed "apparmor=" |
| 256 | return []string{"apparmor="}, cobra.ShellCompDirectiveNoSpace |
| 257 | } |
| 258 | if len(toComplete) > 0 && strings.HasPrefix("label", toComplete) { //nolint:gocritic // not swapped, matches partly typed "label" |
| 259 | return []string{"label="}, cobra.ShellCompDirectiveNoSpace |
| 260 | } |
| 261 | if strings.HasPrefix(toComplete, "label=") { |
| 262 | if strings.HasPrefix(toComplete, "label=d") { |
| 263 | return []string{"label=disable"}, cobra.ShellCompDirectiveNoFileComp |
| 264 | } |
| 265 | labels := []string{"disable", "level:", "role:", "type:", "user:"} |
| 266 | return prefixWith("label=", labels), cobra.ShellCompDirectiveNoSpace | cobra.ShellCompDirectiveNoFileComp |
| 267 | } |
| 268 | // length must be > 1 here so that completion of "s" falls through. |
| 269 | if len(toComplete) > 1 && strings.HasPrefix("seccomp", toComplete) { //nolint:gocritic // not swapped, matches partly typed "seccomp" |
| 270 | return []string{"seccomp="}, cobra.ShellCompDirectiveNoSpace |
| 271 | } |
| 272 | if strings.HasPrefix(toComplete, "seccomp=") { |
| 273 | return []string{"seccomp=unconfined"}, cobra.ShellCompDirectiveNoFileComp |
| 274 | } |
| 275 | return []string{"apparmor=", "label=", "no-new-privileges", "seccomp=", "systempaths=unconfined"}, cobra.ShellCompDirectiveNoFileComp |
| 276 | } |
| 277 | |
| 278 | // completeStorageOpt implements shell completion for the `--storage-opt` option of `run` and `create`. |
| 279 | func completeStorageOpt(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { |
searching dependent graphs…