MCPcopy Index your code
hub / github.com/docker/cli / completeSecurityOpt

Function completeSecurityOpt

cli/command/container/completion.go:254–276  ·  view source on GitHub ↗

completeSecurityOpt implements shell completion for the `--security-opt` option of `run` and `create`. The completion is partly composite.

(_ *cobra.Command, _ []string, toComplete string)

Source from the content-addressed store, hash-verified

252// completeSecurityOpt implements shell completion for the `--security-opt` option of `run` and `create`.
253// The completion is partly composite.
254func 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`.
279func completeStorageOpt(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {

Callers 1

TestCompleteSecurityOptFunction · 0.85

Calls 1

prefixWithFunction · 0.70

Tested by 1

TestCompleteSecurityOptFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…