Refactor hardcoded environment variables in common.yaml

Removed hardcoded environment variables from the `common.yaml` template and
refactored them to utilize the newly structured values from `Values.controllers.main.containers.main.env`.
This change enhances maintainability and clarity by aligning environmental
variables with the current values schema. Additionally, the code was cleaned
up by ensuring proper indentation and structure for readability.
No breaking changes or significant shifts in functionality were introduced;
the refactor merely improves the organization of environment configuration.
This commit is contained in:
2025-11-23 14:05:37 +01:00
parent 5f201ba918
commit ac8181519c

View File

@@ -1,50 +1,50 @@
{{/* Append the hardcoded settings */}} {{/* Append the hardcoded settings */}}
{{- define "healthchecks.harcodedValues" -}} {{- define "healthchecks.harcodedValues" -}}
env: PAPERLESS_TIME_ZONE: {{ .Values.controllers.main.containers.main.env.TZ }}
PAPERLESS_TIME_ZONE: {{ .Values.env.TZ }} PAPERLESS_PORT: {{ quote .Values.service.main.ports.http.port }}
PAPERLESS_PORT: {{ quote .Values.service.main.ports.http.port }}
{{- with .Values.ingress.main }} {{- with .Values.ingress.main }}
{{- if and .enabled .hosts }} {{- if and .enabled .hosts }}
PAPERLESS_URL: http{{ if .tls }}s{{ end }}://{{ (first .hosts).host }} PAPERLESS_URL: http{{ if .tls }}s{{ end }}://{{ (first .hosts).host }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if .Values.postgresql.enabled }} {{- if .Values.postgresql.enabled }}
{{- with .Values.postgresql }} {{- with .Values.postgresql }}
PAPERLESS_DBENGINE: postgresql PAPERLESS_DBENGINE: postgresql
PAPERLESS_DBHOST: {{ $.Release.Name }}-postgresql PAPERLESS_DBHOST: {{ $.Release.Name }}-postgresql
PAPERLESS_DBNAME: {{ .auth.database }} PAPERLESS_DBNAME: {{ .auth.database }}
PAPERLESS_DBUSER: {{ default "postgres" .auth.username }} PAPERLESS_DBUSER: {{ default "postgres" .auth.username }}
PAPERLESS_DBPASS: PAPERLESS_DBPASS:
secretKeyRef: secretKeyRef:
name: {{ .auth.existingSecret | default (printf "%s-postgresql" $.Release.Name) }} name: {{ .auth.existingSecret | default (printf "%s-postgresql" $.Release.Name) }}
key: {{ if not .auth.password }}postgres-{{ end }}password key: {{ if not .auth.password }}postgres-{{ end }}password
{{- end }} {{- end }}
{{- else if .Values.mariadb.enabled }} {{- else if .Values.mariadb.enabled }}
{{- with .Values.mariadb}} {{- with .Values.mariadb}}
PAPERLESS_DBENGINE: mariadb PAPERLESS_DBENGINE: mariadb
PAPERLESS_DBHOST: {{ $.Release.Name }}-mariadb PAPERLESS_DBHOST: {{ $.Release.Name }}-mariadb
PAPERLESS_DBNAME: {{ .auth.database }} PAPERLESS_DBNAME: {{ .auth.database }}
PAPERLESS_DBUSER: {{ .auth.username }} PAPERLESS_DBUSER: {{ .auth.username }}
PAPERLESS_DBPASS: PAPERLESS_DBPASS:
secretKeyRef: secretKeyRef:
name: {{ .auth.existingSecret | default (printf "%s-mariadb" $.Release.Name) }} name: {{ .auth.existingSecret | default (printf "%s-mariadb" $.Release.Name) }}
key: mariadb-password key: mariadb-password
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if .Values.redis.enabled }} {{- if .Values.redis.enabled }}
{{- with .Values.redis }} {{- with .Values.redis }}
A_REDIS_PASSWORD: A_REDIS_PASSWORD:
secretKeyRef: secretKeyRef:
name: {{ .auth.existingSecret | default (printf "%s-redis" $.Release.Name) }} name: {{ .auth.existingSecret | default (printf "%s-redis" $.Release.Name) }}
key: {{ .auth.existingSecretPasswordKey | default "redis-password" }} key: {{ .auth.existingSecretPasswordKey | default "redis-password" }}
PAPERLESS_REDIS: redis://{{ .auth.username }}:$(A_REDIS_PASSWORD)@{{ $.Release.Name }}-redis-master PAPERLESS_REDIS: redis://{{ .auth.username }}:$(A_REDIS_PASSWORD)@{{ $.Release.Name }}-redis-master
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- $_ := merge .Values (include "healthchecks.harcodedValues" . | fromYaml) -}} {{- /* Mergt die Umgebungsvariablen in den 'env'-Block des Haupt-Containers */ -}}
{{- $_ := mergeOverwrite .Values.controllers.main.containers.main.env (include "healthchecks.harcodedValues" . | fromYaml) -}}
{{/* Render the templates */}} {{/* Render the templates */}}
{{ include "bjw-s.common.loader.all" . }} {{ include "bjw-s.common.loader.all" . }}