Skip to content

Commit 99d04f7

Browse files
ComputerBaermrueg
authored andcommitted
fix: empty annotation lists could result in invalid yaml
Signed-off-by: Dominik Strebinger <[email protected]>
1 parent 925ca63 commit 99d04f7

File tree

5 files changed

+38
-16
lines changed

5 files changed

+38
-16
lines changed

charts/coredns/templates/configmap-autoscaler.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ metadata:
1818
{{- if .Values.customLabels }}
1919
{{- toYaml .Values.customLabels | nindent 4 }}
2020
{{- end }}
21-
{{ if or .Values.autoscaler.configmap.annotations .Values.customAnnotations }}
21+
{{- if or .Values.autoscaler.configmap.annotations .Values.customAnnotations }}
2222
annotations:
23-
{{ toYaml .Values.customAnnotations | indent 4 }}
24-
{{- toYaml .Values.autoscaler.configmap.annotations | nindent 4 }}
25-
{{- end }}
23+
{{- if .Values.customAnnotations }}
24+
{{- toYaml .Values.customAnnotations | nindent 4 }}
25+
{{- end }}
26+
{{- if .Values.autoscaler.configmap.annotations -}}
27+
{{ toYaml .Values.autoscaler.configmap.annotations | nindent 4 }}
28+
{{- end }}
29+
{{- end }}
2630
data:
2731
# When cluster is using large nodes(with more cores), "coresPerReplica" should dominate.
2832
# If using small nodes, "nodesPerReplica" should dominate.

charts/coredns/templates/deployment.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ metadata:
1818
{{- if .Values.customLabels }}
1919
{{ toYaml .Values.customLabels | indent 4 }}
2020
{{- end }}
21-
{{ if or .Values.deployment.annotations .Values.customAnnotations }}
21+
{{- if or .Values.deployment.annotations .Values.customAnnotations }}
2222
annotations:
23-
{{ toYaml .Values.customAnnotations | indent 4 }}
24-
{{ toYaml .Values.deployment.annotations | indent 4 }}
25-
{{- end }}
23+
{{- if .Values.customAnnotations }}
24+
{{- toYaml .Values.customAnnotations | nindent 4 }}
25+
{{- end }}
26+
{{- if .Values.deployment.annotations }}
27+
{{- toYaml .Values.deployment.annotations | nindent 4 }}
28+
{{- end }}
29+
{{- end }}
2630
spec:
2731
{{- if not .Values.autoscaler.enabled }}
2832
replicas: {{ .Values.replicaCount }}

charts/coredns/templates/service-metrics.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ metadata:
1717
{{- if .Values.customLabels }}
1818
{{ toYaml .Values.customLabels | indent 4 }}
1919
{{- end }}
20+
{{- if or .Values.prometheus.service.annotations .Values.service.annotations .Values.customAnnotations }}
2021
annotations:
22+
{{- if .Values.prometheus.service.annotations }}
2123
{{ toYaml .Values.prometheus.service.annotations | indent 4 }}
24+
{{- end }}
25+
{{- if .Values.service.annotations }}
2226
{{ toYaml .Values.service.annotations | indent 4 }}
27+
{{- end }}
2328
{{- if .Values.customAnnotations }}
2429
{{ toYaml .Values.customAnnotations | indent 4 }}
2530
{{- end }}
31+
{{- end }}
2632
spec:
2733
selector:
2834
app.kubernetes.io/instance: {{ .Release.Name | quote }}

charts/coredns/templates/service.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ metadata:
1717
{{- if .Values.customLabels }}
1818
{{ toYaml .Values.customLabels | indent 4 }}
1919
{{- end }}
20+
{{- if or .Values.service.annotations .Values.customAnnotations }}
2021
annotations:
21-
{{ toYaml .Values.service.annotations | indent 4 }}
22-
{{- if .Values.customAnnotations }}
23-
{{ toYaml .Values.customAnnotations | indent 4 }}
24-
{{- end }}
22+
{{- if .Values.service.annotations }}
23+
{{- toYaml .Values.service.annotations | nindent 4 }}
24+
{{- end }}
25+
{{- if .Values.customAnnotations }}
26+
{{- toYaml .Values.customAnnotations | nindent 4 }}
27+
{{- end }}
28+
{{- end }}
2529
spec:
2630
selector:
2731
app.kubernetes.io/instance: {{ .Release.Name | quote }}

charts/coredns/templates/serviceaccount.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ metadata:
1313
kubernetes.io/name: "CoreDNS"
1414
{{- end }}
1515
app.kubernetes.io/name: {{ template "coredns.name" . }}
16-
{{ if or .Values.serviceAccount.annotations .Values.customAnnotations }}
16+
{{- if or .Values.serviceAccount.annotations .Values.customAnnotations }}
1717
annotations:
18-
{{ toYaml .Values.customAnnotations | indent 4 }}
19-
{{ toYaml .Values.serviceAccount.annotations | indent 4 }}
20-
{{- end }}
18+
{{- if .Values.customAnnotations }}
19+
{{- toYaml .Values.customAnnotations | nindent 4 }}
20+
{{- end }}
21+
{{- if .Values.serviceAccount.annotations }}
22+
{{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
23+
{{- end }}
24+
{{- end }}
2125
{{- if .Values.image.pullSecrets }}
2226
imagePullSecrets:
2327
{{- range .Values.image.pullSecrets }}

0 commit comments

Comments
 (0)