Fixed disable webhook script

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2022-03-15 09:29:05 +00:00
parent 4528e35872
commit 15ae2e615a
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78

View File

@ -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