Added flux-pause

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2023-05-12 10:52:11 +01:00
parent 7f795ef69a
commit 3d1da1e586
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78

59
home/.bin/flux-pause Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env bash
source .utils
set -e
VERBOSE=""
TARGET_RESOURCE="kustomization"
NAMESPACES="-n flux-system"
print_usage() {
blue "flux-pause - Suspends Flux Kustomization resources"
echo " "
underline "Usage:"
echo "flux-pause [options] RESOURCE_NAME..."
echo " "
underline "Options:"
echo "-n, --namespace the namespace resources belong in. Default: flux-system"
echo "-v --verbose show full verbose output"
echo "-h, --help show this help text"
}
RESOURCES=()
while test $# -gt 0; do
case "$1" in
-h|--help)
print_usage
exit 0
;;
-n|--namespace)
shift
NAMESPACES="-n $1"
shift
;;
-v|--verbose)
VERBOSE="true"
shift
;;
*)
RESOURCES+=(${1})
shift
;;
esac
done
for RESOURCE in ${RESOURCES[@]}
do
printf "Pausing '${RESOURCE}'..."
if [[ "${VERBOSE}" == "true" ]]; then
echo ""
flux suspend kustomization ${RESOURCE} || true
else
flux suspend kustomization ${RESOURCE} &> /dev/null || true
printf " ✅"
fi
echo ""
done