2023-05-12 09:52:11 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
source .utils
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
VERBOSE=""
|
2024-02-13 12:44:24 +00:00
|
|
|
ALL=""
|
2023-05-12 09:52:11 +00:00
|
|
|
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:"
|
2024-02-13 12:44:24 +00:00
|
|
|
echo " --all pause all Kustomizations"
|
2023-05-12 09:52:11 +00:00
|
|
|
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
|
|
|
|
;;
|
2024-02-13 12:44:24 +00:00
|
|
|
--all)
|
|
|
|
ALL="true"
|
|
|
|
shift
|
|
|
|
;;
|
2023-05-12 09:52:11 +00:00
|
|
|
*)
|
|
|
|
RESOURCES+=(${1})
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2024-02-13 12:44:24 +00:00
|
|
|
if [[ "${ALL}" == "true" ]]; then
|
|
|
|
RESOURCES=$(kubectl get kustomization ${NAMESPACES} -o json | jq -r '.items[] | "\( .metadata.name)"')
|
|
|
|
fi
|
2023-05-12 09:52:11 +00:00
|
|
|
|
|
|
|
for RESOURCE in ${RESOURCES[@]}
|
|
|
|
do
|
|
|
|
printf "Pausing '${RESOURCE}'..."
|
|
|
|
if [[ "${VERBOSE}" == "true" ]]; then
|
|
|
|
echo ""
|
2023-06-08 09:29:45 +00:00
|
|
|
flux suspend kustomization ${NAMESPACES} ${RESOURCE} || true
|
2023-05-12 09:52:11 +00:00
|
|
|
else
|
2023-06-08 09:29:45 +00:00
|
|
|
flux suspend kustomization ${NAMESPACES} ${RESOURCE} &> /dev/null || true
|
2023-05-12 09:52:11 +00:00
|
|
|
printf " ✅"
|
|
|
|
fi
|
|
|
|
echo ""
|
|
|
|
done
|