From 12607b8b683fed1334d59929a4f7d50e31af385f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20=C4=8Cekrli=C4=87?= Date: Fri, 27 Oct 2023 10:49:00 +0200 Subject: [PATCH] Fix: Fix How DNS policy and Config is injected into pod Of course, the issue was YAML indending and spacing. --- helm/mail/templates/statefulset.yaml | 24 ++---------------------- helm/test_14_test_dns_policy.yml | 10 +++++----- helm/tests.sh | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/helm/mail/templates/statefulset.yaml b/helm/mail/templates/statefulset.yaml index e7087a4..7756b87 100644 --- a/helm/mail/templates/statefulset.yaml +++ b/helm/mail/templates/statefulset.yaml @@ -177,30 +177,10 @@ spec: {{- tpl .Values.extraContainers $root | nindent 8 }} {{- end }} {{- if .Values.dns.policy }} - dnsPolicy: {{- .Values.dns.policy }} + dnsPolicy: {{ .Values.dns.policy | quote }} {{- end }} {{- if or .Values.dns.nameservers .Values.dns.searches .Values.dns.options }} - dnsConfig: - {{- if .Values.dns.nameservers }} - nameservers: - {{- range .Values.dns.nameservers }} - - {{ . }} - {{- end }} - {{- end }} - {{- if .Values.dns.searches }} - searches: {{- .Values.dns.searches | nindent 4 }} - {{- end }} - {{- if .Values.dns.options }} - options: - {{- range .Values.dns.options }} - {{- if .name }} - - name: {{ .name }} - {{- if .value }} - value: {{ .value | quote }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} + dnsConfig: {{- toYaml (omit .Values.dns "policy") | nindent 8 }} {{- end }} volumes: {{- if .Values.certs.create }} diff --git a/helm/test_14_test_dns_policy.yml b/helm/test_14_test_dns_policy.yml index 60b254f..e70ee6d 100644 --- a/helm/test_14_test_dns_policy.yml +++ b/helm/test_14_test_dns_policy.yml @@ -1,10 +1,10 @@ dns: policy: "None" nameservers: - - 8.8.8.8 - - 8.8.4.4 + - "8.8.8.8" + - "8.8.4.4" searches: "default.svc.cluster.local svc.cluster.local cluster.local" options: - ndots: - - name: ndots - value: "5" + - name: ndots + value: "5" + - name: edns0 \ No newline at end of file diff --git a/helm/tests.sh b/helm/tests.sh index d2f727b..646d27c 100755 --- a/helm/tests.sh +++ b/helm/tests.sh @@ -11,7 +11,8 @@ if command -v gfind >/dev/null 2>&2; then FIND="$(which gfind)" fi -for i in `${FIND} -maxdepth 1 -type f -name test\*yml | sort`; do +do_the_test() { + local i="${1}" echo "☆☆☆☆☆☆☆☆☆☆ $i ☆☆☆☆☆☆☆☆☆☆" helm template -f $i --dry-run mail > fixtures/demo.yaml docker run \ @@ -21,4 +22,16 @@ for i in `${FIND} -maxdepth 1 -type f -name test\*yml | sort`; do --force-color \ --additional-schema-locations file:///schemas \ fixtures/demo.yaml -done +} + + +if [[ $# -gt 0 ]]; then + while [[ $# -gt 0 ]]; do + do_the_test "${1}" + shift + done +else + for i in `${FIND} -maxdepth 1 -type f -name test\*yml | sort`; do + do_the_test "${i}" + done +fi \ No newline at end of file