dotfiles/home/.bin/gs-login
Marcus Noble 758298694c
Updated gs-login to remove old flags
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
2022-02-22 10:16:24 +00:00

64 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
DEBUG=""
print_usage() {
echo "gs-login - login to Giant Swarm managed clusters"
echo " "
echo "gs-login [INSTALLATION] [WORKLOAD CLUSTER] [ORGANISATION]"
echo " "
echo "Examples:"
echo "> gs-login gauss"
echo "> gs-login gauss mywc1"
echo " "
echo "Options:"
echo "-h, --help show this help text"
}
POS_ARGS=()
while test $# -gt 0; do
case "$1" in
-t|--ttl)
shift
echo "-t / --ttl no longer handled"
shift
;;
-g|--certificate-group)
shift
echo "-g / --certificate-group no longer handled"
shift
;;
-h|--help)
print_usage
exit 0
;;
--debug)
DEBUG="--level=debug"
shift
;;
/)
# We want to ignore slash seperators between MC and WC
shift
;;
*)
POS_ARGS+=(`echo $1 | tr '/' ' '`)
shift
;;
esac
done
if [ ${#POS_ARGS[@]} -eq 0 ]; then
POS_ARGS+=(`opsctl list installations --short | tr ' ' '\n' | fzf`)
fi
case ${#POS_ARGS[@]} in
0)
print_usage
exit 1
;;
*)
opsctl login ${DEBUG} ${POS_ARGS[@]}
;;
esac