Created
January 18, 2019 01:54
-
-
Save andrewpolidori/50af405df3897eec02a35c2ce25ee69e to your computer and use it in GitHub Desktop.
Delete releases described FAILED in helm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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