cleaned up validate_private_ingress

This commit is contained in:
Jonas Forsberg 2022-04-06 14:53:29 +02:00
parent 549401d356
commit 7e44dc3985
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9

View File

@ -40,6 +40,9 @@ function validate_private_ingress(){
local OK='\e[32m\u2714\e[0m' local OK='\e[32m\u2714\e[0m'
local NOT_OK='\u274c' local NOT_OK='\u274c'
printf "Validating ingresses in private project (%s}\n" "$PRIVATE_PROJECT_ID" printf "Validating ingresses in private project (%s}\n" "$PRIVATE_PROJECT_ID"
printf "%-22s %s\n" "namespace" "ingress"
printf -- '-%.0s' {1..30}
printf "\n"
for NS in $(kubectl get namespaces --selector=field.cattle.io/projectId="$PRIVATE_PROJECT_ID" --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do for NS in $(kubectl get namespaces --selector=field.cattle.io/projectId="$PRIVATE_PROJECT_ID" --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do
for INGRESS in $(kubectl --namespace "$NS" get ingress --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do for INGRESS in $(kubectl --namespace "$NS" get ingress --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do
if [[ $(kubectl --namespace "$NS" get ingress "$INGRESS" -o jsonpath='{.metadata.annotations.nginx\.ingress\.kubernetes\.io/whitelist-source-range}') == "$WHITELIST_SOURCE_RANGE" ]];then if [[ $(kubectl --namespace "$NS" get ingress "$INGRESS" -o jsonpath='{.metadata.annotations.nginx\.ingress\.kubernetes\.io/whitelist-source-range}') == "$WHITELIST_SOURCE_RANGE" ]];then