fix(helm): render when an upgrade reuses values from before the database block

The templates read the database settings through a default dict, so helm upgrade --reuse-values from a release without them no longer stops on a nil pointer; CI renders the chart with the block removed.
This commit is contained in:
Maurice
2026-11-23 15:08:02 +01:00
parent ca367d9cfc
commit 485fb93f78
3 changed files with 11 additions and 8 deletions
+1
View File
@@ -1187,6 +1187,7 @@ jobs:
--set 'extraVolumeMounts[0].mountPath=/usr/local/share/kitinerary/extractors' \
--set 'extraVolumeMounts[0].readOnly=true' \
--set probes.liveness=null \
--set database=null \
> "$out/variants.yaml"
helm template trek charts/trek \
--set httpRoute.enabled=true \
+5 -4
View File
@@ -1,4 +1,5 @@
{{- if and .Values.database.url (not .Values.database.existingSecret) .Values.existingSecret }}
{{- $db := default dict .Values.database }}
{{- if and $db.url (not $db.existingSecret) .Values.existingSecret }}
{{- fail "database.url is written into the chart's own Secret, which existingSecret replaces. Put TREK_DB_URL in your Secret and set database.existingSecret instead." }}
{{- end }}
apiVersion: apps/v1
@@ -66,13 +67,13 @@ spec:
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) .Values.existingSecret }}
key: {{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}
optional: true
{{- if or .Values.database.url .Values.database.existingSecret }}
{{- if or $db.url $db.existingSecret }}
# Required when set: a missing key stops the pod rather than starting it on SQLite.
- name: TREK_DB_URL
valueFrom:
secretKeyRef:
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) .Values.database.existingSecret }}
key: {{ if .Values.database.existingSecret }}{{ .Values.database.existingSecretKey | default "TREK_DB_URL" }}{{ else }}TREK_DB_URL{{ end }}
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) $db.existingSecret }}
key: {{ if $db.existingSecret }}{{ $db.existingSecretKey | default "TREK_DB_URL" }}{{ else }}TREK_DB_URL{{ end }}
{{- end }}
- name: ADMIN_EMAIL
valueFrom:
+5 -4
View File
@@ -1,3 +1,4 @@
{{- $db := default dict .Values.database }}
{{- if and (not .Values.existingSecret) (not .Values.generateEncryptionKey) }}
apiVersion: v1
kind: Secret
@@ -8,8 +9,8 @@ metadata:
type: Opaque
data:
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ .Values.secretEnv.ENCRYPTION_KEY | b64enc | quote }}
{{- if .Values.database.url }}
TREK_DB_URL: {{ .Values.database.url | b64enc | quote }}
{{- if $db.url }}
TREK_DB_URL: {{ $db.url | b64enc | quote }}
{{- end }}
{{- if .Values.secretEnv.ADMIN_EMAIL }}
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | b64enc | quote }}
@@ -68,8 +69,8 @@ stringData:
{{- else }}
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ randAlphaNum 32 | quote }}
{{- end }}
{{- if .Values.database.url }}
TREK_DB_URL: {{ .Values.database.url | quote }}
{{- if $db.url }}
TREK_DB_URL: {{ $db.url | quote }}
{{- end }}
{{- if .Values.secretEnv.ADMIN_EMAIL }}
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | quote }}