scwrypts/plugins/kubectl/set-context

42 lines
786 B
Plaintext
Raw Permalink Normal View History

#!/bin/zsh
use kubectl --group kubectl
#####################################################################
MAIN() {
local USAGE="
usage: [context] [...options...]
args:
context (optional) the full name of the kubeconfig context to set
options:
--subsession REDIS subsession (default 0)
-h, --help show this dialogue and exit
"
local CONTEXT
local SUBSESSION=0
while [[ $# -gt 0 ]]
do
case $1 in
--subsession ) SUBSESSION=$2; shift 1 ;;
-h | --help ) USAGE; return 0 ;;
* )
[ $CONTEXT ] && ERROR "unexpected argument '$2'"
CONTEXT=$1
;;
esac
shift 1
done
[ $CONTEXT ] || CONTEXT=$(KUBECTL__SELECT_CONTEXT)
[ $CONTEXT ] || ERROR 'must provide or select a valid kube context'
CHECK_ERRORS
KUBECTL__SET_CONTEXT $CONTEXT
}