Files
scwrypts/plugins/kube/set-namespace
T

42 lines
854 B
Bash
Raw Normal View History

2024-05-10 13:32:02 -06:00
#!/usr/bin/env zsh
use kubectl --group kube
2023-08-28 18:42:38 -06:00
#####################################################################
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:
2024-05-10 13:32:02 -06:00
--subsession kube.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 ;;
2024-05-10 13:32:02 -06:00
-h | --help ) utils.io.usage; return 0 ;;
2023-11-22 15:54:16 -07:00
2023-08-30 17:26:13 -06:00
* )
2024-05-10 13:32:02 -06:00
[ $NAMESPACE ] && echo.error "unexpected argument '$2'"
2023-08-30 17:26:13 -06:00
NAMESPACE=$1
;;
esac
shift 1
done
2024-05-10 13:32:02 -06:00
[ $NAMESPACE ] || NAMESPACE=$(kube.kubectl.namespace.select)
[ $NAMESPACE ] || echo.error 'must provide or select a valid namespace'
2023-08-28 18:42:38 -06:00
2024-05-10 13:32:02 -06:00
utils.check-errors --fail
2023-08-28 18:42:38 -06:00
2024-05-10 13:32:02 -06:00
kube.kubectl.namespace.set $NAMESPACE
2023-08-28 18:42:38 -06:00
}