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 */}}
{{- define "prometheus-postgres-exporter.deployment.volumeMounts" -}}
{{- $volumeMounts := dict "volumeMounts" (.Values.deployment.postgresExporter.volumeMounts | default (list) ) }}
{{- $volumeMounts = merge $volumeMounts (dict "volumeMounts" (list (dict "name" "config-d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" ))) }}
{{ toYaml $volumeMounts }}
{{- $volumeMounts := .Values.deployment.postgresExporter.volumeMounts | default list }}
{{- $volumeMounts = concat $volumeMounts (list (dict "name" "config-d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" )) }}
{{ toYaml (dict "volumeMounts" $volumeMounts) }}
{{- end -}}
{{/* 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 -}}
{{- if not .Values.config.exporterConfig.existingSecret.enabled }}
@ -72,8 +72,8 @@
{{- $webConfigSecretName = printf "%s-web-config" (include "prometheus-postgres-exporter.fullname" . ) }}
{{- 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 -}}

View File

@ -352,14 +352,24 @@ tests:
hostPath:
path: /usr/lib/prometheus-postgres-exporter/data
asserts:
- contains:
- equal:
path: spec.template.spec.containers[0].volumeMounts
content:
name: data
value:
- name: 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
content:
name: data
value:
- name: data
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