Files
scwrypts/plugins/kubectl/set-namespace
T

42 lines
804 B
Bash
Raw Permalink Normal View History

2023-08-28 18:42:38 -06:00
#!/bin/zsh
use kubectl --group kubectl
#####################################################################
MAIN() {
local USAGE="
2023-08-30 17:26:13 -06:00
usage: [namespace] [...options...]
2023-08-28 18:42:38 -06:00
args:
2023-08-30 17:26:13 -06:00
namespace (optional) the full name of the namespace context to set
options:
--subsession REDIS subsession (default 0)
2023-11-22 15:54:16 -07:00
-h, --help show this dialogue and exit
2023-08-28 18:42:38 -06:00
"
2023-08-30 17:26:13 -06:00
local NAMESPACE
local SUBSESSION=0
while [[ $# -gt 0 ]]
do
case $1 in
--subsession ) SUBSESSION=$2; shift 1 ;;
2023-11-22 15:54:16 -07:00
-h | --help ) USAGE; return 0 ;;
2023-08-30 17:26:13 -06:00
* )
[ $NAMESPACE ] && ERROR "unexpected argument '$2'"
NAMESPACE=$1
;;
esac
shift 1
done
[ $NAMESPACE ] || NAMESPACE=$(KUBECTL__SELECT_NAMESPACE)
2023-08-28 18:42:38 -06:00
[ $NAMESPACE ] || ERROR 'must provide or select a valid namespace'
CHECK_ERRORS
KUBECTL__SET_NAMESPACE $NAMESPACE
}