Merge pull request #31135 from xingzhou/bash_completion_bug

Automatic merge from submit-queue

Fixed two issues of kubectl bash completion.

This patch includes the fix of the following issue:
• Correct the method invocation from "__kubectl_namespace_flag"
  to "__kubectl_override_flags"
• Support bash completion if "--namespace=xxx" style flags are
  specified in the kubectl command

Fixes #31134
This commit is contained in:
Kubernetes Submit Queue 2016-08-24 23:43:20 -07:00 committed by GitHub
commit bdeeb9db90

View File

@ -47,7 +47,7 @@ __kubectl_override_flags()
for of in "${__kubectl_override_flag_list[@]}"; do for of in "${__kubectl_override_flag_list[@]}"; do
case "${w}" in case "${w}" in
--${of}=*) --${of}=*)
eval "${of}=\"--${of}=\${w}\"" eval "${of}=\"${w}\""
;; ;;
--${of}) --${of})
two_word_of="${of}" two_word_of="${of}"
@ -115,7 +115,7 @@ __kubectl_get_containers()
fi fi
local last=${nouns[${len} -1]} local last=${nouns[${len} -1]}
local kubectl_out local kubectl_out
if kubectl_out=$(kubectl get $(__kubectl_namespace_flag) -o template --template="${template}" pods "${last}" 2>/dev/null); then if kubectl_out=$(kubectl get $(__kubectl_override_flags) -o template --template="${template}" pods "${last}" 2>/dev/null); then
COMPREPLY=( $( compgen -W "${kubectl_out[*]}" -- "$cur" ) ) COMPREPLY=( $( compgen -W "${kubectl_out[*]}" -- "$cur" ) )
fi fi
} }