2021-11-29 08:07:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-12-07 10:08:44 +00:00
|
|
|
DEBUG=""
|
2021-11-29 08:07:17 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2021-12-07 10:08:44 +00:00
|
|
|
POS_ARGS=()
|
|
|
|
|
2021-11-29 08:07:17 +00:00
|
|
|
while test $# -gt 0; do
|
|
|
|
case "$1" in
|
|
|
|
-t|--ttl)
|
|
|
|
shift
|
2022-02-22 10:16:24 +00:00
|
|
|
echo "-t / --ttl no longer handled"
|
2021-11-29 08:07:17 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-g|--certificate-group)
|
|
|
|
shift
|
2022-02-22 10:16:24 +00:00
|
|
|
echo "-g / --certificate-group no longer handled"
|
2021-11-29 08:07:17 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-h|--help)
|
|
|
|
print_usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2021-12-07 10:08:44 +00:00
|
|
|
--debug)
|
2022-02-22 10:16:24 +00:00
|
|
|
DEBUG="--level=debug"
|
2021-12-07 10:08:44 +00:00
|
|
|
shift
|
2021-12-07 12:44:20 +00:00
|
|
|
;;
|
2021-12-07 10:08:44 +00:00
|
|
|
/)
|
|
|
|
# We want to ignore slash seperators between MC and WC
|
|
|
|
shift
|
|
|
|
;;
|
2021-11-29 08:07:17 +00:00
|
|
|
*)
|
2021-12-07 10:08:44 +00:00
|
|
|
POS_ARGS+=(`echo $1 | tr '/' ' '`)
|
|
|
|
shift
|
2021-11-29 08:07:17 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-12-14 08:07:58 +00:00
|
|
|
if [ ${#POS_ARGS[@]} -eq 0 ]; then
|
|
|
|
POS_ARGS+=(`opsctl list installations --short | tr ' ' '\n' | fzf`)
|
|
|
|
fi
|
|
|
|
|
2021-12-07 10:08:44 +00:00
|
|
|
case ${#POS_ARGS[@]} in
|
2022-02-22 10:16:24 +00:00
|
|
|
0)
|
2021-11-29 08:07:17 +00:00
|
|
|
print_usage
|
|
|
|
exit 1
|
|
|
|
;;
|
2022-02-22 10:16:24 +00:00
|
|
|
*)
|
|
|
|
opsctl login ${DEBUG} ${POS_ARGS[@]}
|
|
|
|
;;
|
2021-11-29 08:07:17 +00:00
|
|
|
esac
|