fix(deployment): concat lists correctly
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Markus Pesch 2024-11-26 21:01:45 +01:00
parent dcc7bae921
commit 94fbc5e38f
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 23 additions and 13 deletions

View File

@ -52,15 +52,15 @@
{{/* volumeMounts */}} {{/* volumeMounts */}}
{{- define "prometheus-postgres-exporter.deployment.volumeMounts" -}} {{- define "prometheus-postgres-exporter.deployment.volumeMounts" -}}
{{- $volumeMounts := dict "volumeMounts" (.Values.deployment.postgresExporter.volumeMounts | default (list) ) }} {{- $volumeMounts := .Values.deployment.postgresExporter.volumeMounts | default list }}
{{- $volumeMounts = merge $volumeMounts (dict "volumeMounts" (list (dict "name" "config-d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" ))) }} {{- $volumeMounts = concat $volumeMounts (list (dict "name" "config-d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" )) }}
{{ toYaml $volumeMounts }} {{ toYaml (dict "volumeMounts" $volumeMounts) }}
{{- end -}} {{- end -}}
{{/* volumes */}} {{/* volumes */}}
{{- define "prometheus-postgres-exporter.deployment.volumes" -}} {{- define "prometheus-postgres-exporter.deployment.volumes" -}}
{{- $volumes := dict "volumes" (.Values.deployment.volumes | default (list) ) }} {{- $volumes := .Values.deployment.volumes | default list }}
{{- $exporterSecretName := .Values.config.exporterConfig.existingSecret.secretName -}} {{- $exporterSecretName := .Values.config.exporterConfig.existingSecret.secretName -}}
{{- if not .Values.config.exporterConfig.existingSecret.enabled }} {{- if not .Values.config.exporterConfig.existingSecret.enabled }}
@ -72,8 +72,8 @@
{{- $webConfigSecretName = printf "%s-web-config" (include "prometheus-postgres-exporter.fullname" . ) }} {{- $webConfigSecretName = printf "%s-web-config" (include "prometheus-postgres-exporter.fullname" . ) }}
{{- end }} {{- end }}
{{- $volumes = merge $volumes (dict "volumes" (list (dict "name" "config-d" "projected" (dict "defaultMode" 444 "sources" (list (dict "secret" (dict "name" $exporterSecretName)) (dict "secret" (dict "name" $webConfigSecretName))))))) }} {{- $volumes = concat $volumes (list (dict "name" "config-d" "projected" (dict "defaultMode" 444 "sources" (list (dict "secret" (dict "name" $exporterSecretName)) (dict "secret" (dict "name" $webConfigSecretName)))))) }}
{{ toYaml $volumes }} {{ toYaml (dict "volumes" $volumes) }}
{{- end -}} {{- end -}}

View File

@ -352,14 +352,24 @@ tests:
hostPath: hostPath:
path: /usr/lib/prometheus-postgres-exporter/data path: /usr/lib/prometheus-postgres-exporter/data
asserts: asserts:
- contains: - equal:
path: spec.template.spec.containers[0].volumeMounts path: spec.template.spec.containers[0].volumeMounts
content: value:
name: data - name: data
mountPath: /usr/lib/prometheus-postgres-exporter/data mountPath: /usr/lib/prometheus-postgres-exporter/data
- contains: - name: config-d
mountPath: /etc/prometheus-postgres-exporter/config.d
- equal:
path: spec.template.spec.volumes path: spec.template.spec.volumes
content: value:
name: data - name: data
hostPath: hostPath:
path: /usr/lib/prometheus-postgres-exporter/data path: /usr/lib/prometheus-postgres-exporter/data
- name: config-d
projected:
defaultMode: 444
sources:
- secret:
name: prometheus-postgres-exporter-unittest-exporter-config
- secret:
name: prometheus-postgres-exporter-unittest-web-config