Merge pull request #4 from swestcott/master

Fix context discovery
This commit is contained in:
Ahmet Alp Balkan 2017-05-15 19:34:28 -07:00 committed by GitHub
commit c49f975e45
3 changed files with 5 additions and 6 deletions

View File

@ -2,7 +2,7 @@ _kube_contexts()
{
local curr_arg;
curr_arg=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "- $(kubectl config get-contexts | awk '{print $2}' | tail -n +2)" -- $curr_arg ) );
COMPREPLY=( $(compgen -W "- $(kubectl config get-contexts --output='name')" -- $curr_arg ) );
}
complete -F _kube_contexts kubectx
complete -F _kube_contexts kubectx

View File

@ -6,7 +6,7 @@ if [ -f "$KUBECTX" ]; then
# show '-' only if there's a saved previous context
PREV=$(cat "${KUBECTX}")
_arguments "1: :((-\:Back\ to\ ${PREV} \
$(kubectl config get-contexts | awk '{print $2}' | tail -n +2)))"
$(kubectl config get-contexts --output='name')))"
else
_arguments "1: :($(kubectl config get-contexts | awk '{print $2}' | tail -n +2))"
_arguments "1: :($(kubectl config get-contexts --output='name'))"
fi

View File

@ -40,8 +40,7 @@ current_context() {
}
get_contexts() {
kubectl config view \
-o=jsonpath='{range .contexts[*].name}{@}{"\n"}{end}'
kubectl config get-contexts --output=name
}
list_contexts() {