From 5f201ba91874ac27817d04100270f1c9e7d11cbd Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Sun, 23 Nov 2025 13:12:58 +0100 Subject: [PATCH] Refactor environment variable definitions in common.yaml This commit refactors the environment variable definitions in the `common.yaml` template for the Paperless-ngx chart. The structure has been simplified by removing the unnecessary nested "controllers: main: type: deployment" section, directly defining the `env` block. This improves readability and maintainability of the Helm template. No functional changes were introduced, and existing behaviors are preserved. The refactor aims to streamline the configuration management process for better clarity when setting up environment variables related to services like PostgreSQL, MariaDB, and Redis. --- charts/paperless-ngx/templates/common.yaml | 93 ++++++++++------------ 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/charts/paperless-ngx/templates/common.yaml b/charts/paperless-ngx/templates/common.yaml index cbfc981..e3fdfcc 100644 --- a/charts/paperless-ngx/templates/common.yaml +++ b/charts/paperless-ngx/templates/common.yaml @@ -1,55 +1,50 @@ {{/* Append the hardcoded settings */}} {{- define "healthchecks.harcodedValues" -}} -controllers: - main: - type: deployment - containers: - main: - env: - PAPERLESS_TIME_ZONE: {{ .Values.env.TZ }} - PAPERLESS_PORT: {{ quote .Values.service.main.ports.http.port }} - - {{- with .Values.ingress.main }} - {{- if and .enabled .hosts }} - PAPERLESS_URL: http{{ if .tls }}s{{ end }}://{{ (first .hosts).host }} - {{- end }} - {{- end }} - - {{- if .Values.postgresql.enabled }} - {{- with .Values.postgresql }} - PAPERLESS_DBENGINE: postgresql - PAPERLESS_DBHOST: {{ $.Release.Name }}-postgresql - PAPERLESS_DBNAME: {{ .auth.database }} - PAPERLESS_DBUSER: {{ default "postgres" .auth.username }} - PAPERLESS_DBPASS: - secretKeyRef: - name: {{ .auth.existingSecret | default (printf "%s-postgresql" $.Release.Name) }} - key: {{ if not .auth.password }}postgres-{{ end }}password - {{- end }} - {{- else if .Values.mariadb.enabled }} - {{- with .Values.mariadb}} - PAPERLESS_DBENGINE: mariadb - PAPERLESS_DBHOST: {{ $.Release.Name }}-mariadb - PAPERLESS_DBNAME: {{ .auth.database }} - PAPERLESS_DBUSER: {{ .auth.username }} - PAPERLESS_DBPASS: - secretKeyRef: - name: {{ .auth.existingSecret | default (printf "%s-mariadb" $.Release.Name) }} - key: mariadb-password - {{- end }} - {{- end }} - - {{- if .Values.redis.enabled }} - {{- with .Values.redis }} - A_REDIS_PASSWORD: - secretKeyRef: - name: {{ .auth.existingSecret | default (printf "%s-redis" $.Release.Name) }} - key: {{ .auth.existingSecretPasswordKey | default "redis-password" }} - PAPERLESS_REDIS: redis://{{ .auth.username }}:$(A_REDIS_PASSWORD)@{{ $.Release.Name }}-redis-master - {{- end }} - {{- end }} +env: + PAPERLESS_TIME_ZONE: {{ .Values.env.TZ }} + PAPERLESS_PORT: {{ quote .Values.service.main.ports.http.port }} + + {{- with .Values.ingress.main }} + {{- if and .enabled .hosts }} + PAPERLESS_URL: http{{ if .tls }}s{{ end }}://{{ (first .hosts).host }} + {{- end }} + {{- end }} + + {{- if .Values.postgresql.enabled }} + {{- with .Values.postgresql }} + PAPERLESS_DBENGINE: postgresql + PAPERLESS_DBHOST: {{ $.Release.Name }}-postgresql + PAPERLESS_DBNAME: {{ .auth.database }} + PAPERLESS_DBUSER: {{ default "postgres" .auth.username }} + PAPERLESS_DBPASS: + secretKeyRef: + name: {{ .auth.existingSecret | default (printf "%s-postgresql" $.Release.Name) }} + key: {{ if not .auth.password }}postgres-{{ end }}password + {{- end }} + {{- else if .Values.mariadb.enabled }} + {{- with .Values.mariadb}} + PAPERLESS_DBENGINE: mariadb + PAPERLESS_DBHOST: {{ $.Release.Name }}-mariadb + PAPERLESS_DBNAME: {{ .auth.database }} + PAPERLESS_DBUSER: {{ .auth.username }} + PAPERLESS_DBPASS: + secretKeyRef: + name: {{ .auth.existingSecret | default (printf "%s-mariadb" $.Release.Name) }} + key: mariadb-password + {{- end }} + {{- end }} + + {{- if .Values.redis.enabled }} + {{- with .Values.redis }} + A_REDIS_PASSWORD: + secretKeyRef: + name: {{ .auth.existingSecret | default (printf "%s-redis" $.Release.Name) }} + key: {{ .auth.existingSecretPasswordKey | default "redis-password" }} + PAPERLESS_REDIS: redis://{{ .auth.username }}:$(A_REDIS_PASSWORD)@{{ $.Release.Name }}-redis-master + {{- end }} + {{- end }} {{- end -}} {{- $_ := merge .Values (include "healthchecks.harcodedValues" . | fromYaml) -}} {{/* Render the templates */}} -{{ include "bjw-s.common.loader.all" . }} +{{ include "bjw-s.common.loader.all" . }} \ No newline at end of file