2022-03-02 07:56:15 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-03-11 18:38:32 +00:00
|
|
|
source .utils
|
|
|
|
|
2022-03-02 07:56:15 +00:00
|
|
|
DEBUG=""
|
|
|
|
|
2022-03-11 18:38:32 +00:00
|
|
|
SUPPORTED_APPS="alertmanager cloudprovider grafana happa kibana kyverno prometheus"
|
2022-03-02 07:56:15 +00:00
|
|
|
|
|
|
|
print_usage() {
|
2022-03-11 18:38:32 +00:00
|
|
|
orange "gs-open - open apps on Giant Swarm clusters"
|
2022-03-02 07:56:15 +00:00
|
|
|
echo " "
|
2022-03-11 18:38:32 +00:00
|
|
|
underline "Usage:"
|
2022-03-02 07:56:15 +00:00
|
|
|
echo "gs-open [APP] [INSTALLATION] [WORKLOAD CLUSTER] "
|
|
|
|
echo " "
|
2022-03-11 18:38:32 +00:00
|
|
|
underline "Supported apps:"
|
|
|
|
italic "${SUPPORTED_APPS}"
|
|
|
|
echo " "
|
|
|
|
underline "Examples:"
|
2022-03-02 07:56:15 +00:00
|
|
|
echo "> gs-open prometheus gauss"
|
|
|
|
echo "> gs-open alertmanager gauss mywc1"
|
|
|
|
echo " "
|
2022-03-11 18:38:32 +00:00
|
|
|
underline "Options:"
|
2022-03-02 07:56:15 +00:00
|
|
|
echo "-h, --help show this help text"
|
2022-03-11 18:38:32 +00:00
|
|
|
echo " --debug show debug log output"
|
2022-03-02 07:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
POS_ARGS=()
|
|
|
|
|
|
|
|
while test $# -gt 0; do
|
|
|
|
case "$1" in
|
|
|
|
-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+=(`echo ${SUPPORTED_APPS} | tr ' ' '\n' | fzf`)
|
|
|
|
fi
|
|
|
|
if [ ${#POS_ARGS[@]} -eq 1 ]; then
|
|
|
|
POS_ARGS+=(`opsctl list installations --short | tr ' ' '\n' | fzf`)
|
|
|
|
fi
|
|
|
|
|
2022-03-11 18:38:32 +00:00
|
|
|
APP=${POS_ARGS[0]}
|
|
|
|
if [[ "${APP}" == "cloud" ]]; then
|
|
|
|
APP=cloudprovider
|
|
|
|
fi
|
|
|
|
if [[ "${APP}" == "prom" ]]; then
|
|
|
|
APP=prometheus
|
|
|
|
fi
|
|
|
|
|
2022-03-02 07:56:15 +00:00
|
|
|
case ${#POS_ARGS[@]} in
|
|
|
|
0)
|
|
|
|
print_usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
2)
|
2022-03-11 18:38:32 +00:00
|
|
|
echo "✨ Opening ${APP} on ${POS_ARGS[1]}"
|
|
|
|
opsctl open ${DEBUG} --app ${APP} --installation ${POS_ARGS[1]}
|
2022-03-02 07:56:15 +00:00
|
|
|
;;
|
|
|
|
3)
|
2022-03-11 18:38:32 +00:00
|
|
|
echo "✨ Opening ${APP} on ${POS_ARGS[1]} / ${POS_ARGS[2]}"
|
|
|
|
opsctl open ${DEBUG} --app ${APP} --installation ${POS_ARGS[1]} --workload-cluster ${POS_ARGS[2]}
|
2022-03-02 07:56:15 +00:00
|
|
|
;;
|
|
|
|
esac
|