Skip to content

Instantly share code, notes, and snippets.

@andrewpolidori
Created January 18, 2019 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewpolidori/50af405df3897eec02a35c2ce25ee69e to your computer and use it in GitHub Desktop.
Save andrewpolidori/50af405df3897eec02a35c2ce25ee69e to your computer and use it in GitHub Desktop.
Delete releases described FAILED in helm
#!/bin/bash
usage() {
echo -e "Usage: clean_failed_helm_releases [-h | --help][-d | --dry-run] \n"
echo " -h --help Prints this message\n"
echo " -d --dry-run Simulate deleting the failed releases with helm"
}
# check for correct argumet number
if [[ $# -gt 1 ]]
then
usage
exit 1
fi
while test $# -ge 0; do
case "$1" in
-h|--help)
usage
exit 0
;;
-d|--dry-run)
echo "Dry Run Specified, nothing will be deleted"
for i in $(helm list | grep FAILED | awk '{print $1}'); do
helm delete "$i" --dry-run
done
exit 0
;;
-*)
echo -e "INPUT NOT RECOGNIZED\n"
usage
exit 1
;;
*)
echo -e "DELETING RELEASES\n"
for i in $(helm list | grep FAILED | awk '{print $1}'); do
helm delete "$i"
done
exit 0
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment