From b25a5c4c8d6a6a840baa703e3b3ed7bef6c7effa Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Wed, 6 Apr 2022 05:54:27 +0100 Subject: [PATCH] Tweaked kube-force-delete Signed-off-by: Marcus Noble --- home/.bin/kube-force-delete | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.bin/kube-force-delete b/home/.bin/kube-force-delete index 1f492ff..b1ba3b0 100755 --- a/home/.bin/kube-force-delete +++ b/home/.bin/kube-force-delete @@ -54,7 +54,7 @@ fi function deleteResource() { echo "Deleting ${1}" - kubectl patch -p '{"metadata":{"finalizers":null}}' --type=merge -n ${NAMESPACE} ${1} 1>/dev/null + kubectl patch -p '{"metadata":{"finalizers":null}}' --type=merge -n ${NAMESPACE} ${1} 1>/dev/null|| printf "" kubectl delete -n ${NAMESPACE} ${1} 2>/dev/null || printf "" } @@ -69,7 +69,7 @@ else printf "Are you sure you want to delete all matching '${SELECTOR}'? (y/n): " SELECTOR="-l ${SELECTOR}" NAMES="$(kubectl api-resources --namespaced --verbs list -o name 2>/dev/null | tr '\n' ,)" - RESOURCES=$(kubectl get "${NAMES::${#NAMES}-1}" --ignore-not-found ${SELECTOR} -n ${NAMESPACE} -o go-template='{{range.items}}{{.kind}}.{{.apiVersion}}/{{.metadata.name}}{{"\n"}}{{end}}' | tr '[:upper:]' '[:lower:]' | sed -r "s|/(v.+)/|/|g" 2>/dev/null) + RESOURCES=$(kubectl get "${NAMES::${#NAMES}-1}" --ignore-not-found ${SELECTOR} -n ${NAMESPACE} -o go-template='{{range.items}}{{.kind}}.{{.apiVersion}}/{{.metadata.name}}{{"\n"}}{{end}}' 2>/dev/null | tr '[:upper:]' '[:lower:]' | sed -r "s|/(v.+)/|/|g") fi read CONFIRM