Improved gs-login
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
6ab3606e20
commit
b1ca06ca1c
@ -4,6 +4,7 @@ set -e
|
|||||||
|
|
||||||
TTL="24h"
|
TTL="24h"
|
||||||
CERTIFICATE_GROUP="system:masters"
|
CERTIFICATE_GROUP="system:masters"
|
||||||
|
DEBUG=""
|
||||||
|
|
||||||
print_usage() {
|
print_usage() {
|
||||||
echo "gs-login - login to Giant Swarm managed clusters"
|
echo "gs-login - login to Giant Swarm managed clusters"
|
||||||
@ -20,6 +21,8 @@ print_usage() {
|
|||||||
echo "-g, --certificate-group the certificate group to login as on the workload cluster (default: system:masters)"
|
echo "-g, --certificate-group the certificate group to login as on the workload cluster (default: system:masters)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
POS_ARGS=()
|
||||||
|
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-t|--ttl)
|
-t|--ttl)
|
||||||
@ -36,21 +39,29 @@ while test $# -gt 0; do
|
|||||||
print_usage
|
print_usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
--debug)
|
||||||
|
DEBUG="--debug"
|
||||||
|
shift
|
||||||
|
/)
|
||||||
|
# We want to ignore slash seperators between MC and WC
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
POS_ARGS+=(`echo $1 | tr '/' ' '`)
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
case $# in
|
case ${#POS_ARGS[@]} in
|
||||||
1)
|
1)
|
||||||
kubectl gs login $1 2>/dev/null || opsctl kgs login -i $1
|
kubectl gs login ${POS_ARGS[0]} ${DEBUG} 2>/dev/null || opsctl kgs login -i ${POS_ARGS[0]}
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
kubectl gs login $1 --workload-cluster $2 --certificate-group system:masters --certificate-ttl 24h
|
kubectl gs login ${POS_ARGS[0]} --workload-cluster ${POS_ARGS[1]} --certificate-group ${CERTIFICATE_GROUP} --certificate-ttl ${TTL} ${DEBUG}
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
kubectl gs login $1 --workload-cluster $2 --certificate-group system:masters --certificate-ttl 24h --organization $3
|
kubectl gs login ${POS_ARGS[0]} --workload-cluster ${POS_ARGS[1]} --certificate-group ${CERTIFICATE_GROUP} --certificate-ttl ${TTL} --organization ${POS_ARGS[2]} ${DEBUG}
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
print_usage
|
print_usage
|
||||||
|
Loading…
Reference in New Issue
Block a user