Updated gs-login to remove old flags

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2022-02-22 10:16:24 +00:00
parent 8dcba62bee
commit 758298694c
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78
1 changed files with 7 additions and 24 deletions

View File

@ -1,7 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
TTL="8h"
CERTIFICATE_GROUP="system:masters"
DEBUG="" DEBUG=""
print_usage() { print_usage() {
@ -15,8 +13,6 @@ print_usage() {
echo " " echo " "
echo "Options:" echo "Options:"
echo "-h, --help show this help text" echo "-h, --help show this help text"
echo "-t, --ttl the certificate ttl for the workload cluster login (default: 8h)"
echo "-g, --certificate-group the certificate group to login as on the workload cluster (default: system:masters)"
} }
POS_ARGS=() POS_ARGS=()
@ -25,12 +21,12 @@ while test $# -gt 0; do
case "$1" in case "$1" in
-t|--ttl) -t|--ttl)
shift shift
TTL=$1 echo "-t / --ttl no longer handled"
shift shift
;; ;;
-g|--certificate-group) -g|--certificate-group)
shift shift
CERTIFICATE_GROUP=$1 echo "-g / --certificate-group no longer handled"
shift shift
;; ;;
-h|--help) -h|--help)
@ -38,7 +34,7 @@ while test $# -gt 0; do
exit 0 exit 0
;; ;;
--debug) --debug)
DEBUG="--debug" DEBUG="--level=debug"
shift shift
;; ;;
/) /)
@ -56,25 +52,12 @@ if [ ${#POS_ARGS[@]} -eq 0 ]; then
POS_ARGS+=(`opsctl list installations --short | tr ' ' '\n' | fzf`) POS_ARGS+=(`opsctl list installations --short | tr ' ' '\n' | fzf`)
fi fi
MC_EXIST=$(kubectl config get-contexts --no-headers -o name gs-${POS_ARGS[0]} 2>/dev/null | wc -l | xargs)
case ${#POS_ARGS[@]} in case ${#POS_ARGS[@]} in
1) 0)
opsctl login ${DEBUG} ${POS_ARGS[0]}
;;
2)
opsctl login ${DEBUG} ${POS_ARGS[0]} ${POS_ARGS[1]}
;;
3)
if [ ${MC_EXIST} -eq 0 ]; then gs-login ${POS_ARGS[0]}; fi
ORG_FLAG="--organization ${POS_ARGS[2]}"
if [[ "${POS_ARGS[2]}" == "default" ]]; then
ORG_FLAG="--insecure-namespace"
fi
kubectl gs login ${POS_ARGS[0]} --workload-cluster ${POS_ARGS[1]} --certificate-group ${CERTIFICATE_GROUP} --certificate-ttl ${TTL} ${ORG_FLAG} ${DEBUG}
;;
*)
print_usage print_usage
exit 1 exit 1
;; ;;
*)
opsctl login ${DEBUG} ${POS_ARGS[@]}
;;
esac esac