From 15ae2e615a1dfa3a1faea7c40cc77f79f347920e Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Tue, 15 Mar 2022 09:29:05 +0000 Subject: [PATCH] Fixed disable webhook script Signed-off-by: Marcus Noble --- home/.bin/kube-disable-webhook | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.bin/kube-disable-webhook b/home/.bin/kube-disable-webhook index 62003eb..b9dc977 100755 --- a/home/.bin/kube-disable-webhook +++ b/home/.bin/kube-disable-webhook @@ -39,7 +39,7 @@ FAKE_SELECTOR='"namespaceSelector":{"matchExpressions":[{"key":"disabled","opera if [[ "${WEBHOOK_TYPE}" == "mutating" ]]; then printf "🚫 Disabling mutating webhook ${NAME}..." - kubectl annotate mutatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} previous-state='kubectl get mutatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} -o json' + kubectl annotate mutatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} previous-state="$(kubectl get mutatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} -o json)" &>/dev/null HOOKS=$(kubectl get mutatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} -o go-template='{{range .webhooks}}{{.name}}{{"\n"}}{{end}}') for HOOK in ${HOOKS} do @@ -48,7 +48,7 @@ if [[ "${WEBHOOK_TYPE}" == "mutating" ]]; then printf " ✅ Done" elif [[ "${WEBHOOK_TYPE}" == "validating" ]]; then printf "🚫 Disabling validating webhook ${NAME}..." - kubectl annotate validatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} previous-state='kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} -o json' + kubectl annotate validatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} previous-state="$(kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} -o json)" &>/dev/null HOOKS=$(kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io ${NAME} -o go-template='{{range .webhooks}}{{.name}}{{"\n"}}{{end}}') for HOOK in ${HOOKS} do