From fd2bde68f323ba62131f2921a6c8413123ae9ff1 Mon Sep 17 00:00:00 2001 From: jessebot Date: Fri, 14 Jul 2023 14:16:43 +0200 Subject: [PATCH] fix helm templating issue --- charts/mastodon/dev-values.yaml | 2 +- charts/mastodon/templates/_helpers.tpl | 24 +++++++++++++++++-- .../templates/deployment-sidekiq.yaml | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/charts/mastodon/dev-values.yaml b/charts/mastodon/dev-values.yaml index 8345f32..dce3c75 100644 --- a/charts/mastodon/dev-values.yaml +++ b/charts/mastodon/dev-values.yaml @@ -95,7 +95,7 @@ mastodon: # -- you can also specify the name of an existing Secret # with keys SECRET_KEY_BASE and OTP_SECRET and # VAPID_PRIVATE_KEY and VAPID_PUBLIC_KEY - # existingSecret: "" + existingSecret: "" sidekiq: # -- Pod security context for all Sidekiq Pods, overwrites .Values.podSecurityContext diff --git a/charts/mastodon/templates/_helpers.tpl b/charts/mastodon/templates/_helpers.tpl index 7da08c0..6c0940a 100644 --- a/charts/mastodon/templates/_helpers.tpl +++ b/charts/mastodon/templates/_helpers.tpl @@ -89,9 +89,16 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Get the mastodon secret. +*/}} {{- define "mastodon.secretName" -}} -{{- default "secret" .Values.mastodon.secrets.existingSecret }} -{{- end }} +{{- if .Values.mastodon.secrets.existingSecret }} + {{- printf "%s" (tpl .Values.mastodon.secrets.existingSecret $) -}} +{{- else -}} + {{- printf "%s" (include "common.names.fullname" .) -}} +{{- end -}} +{{- end -}} {{/* Get the smtp secret. @@ -130,6 +137,19 @@ Get the redis secret. {{- end -}} {{- end -}} +{{/* +Return true if a mastodon secret object should be created +*/}} +{{- define "mastodon.createSecret" -}} +{{- if (or + (and .Values.mastodon.s3.enabled (not .Values.mastodon.s3.existingSecret)) + (not .Values.mastodon.secrets.existingSecret ) + (and (not .Values.postgresql.enabled) (not .Values.postgresql.auth.existingSecret)) + ) -}} + {{- true -}} +{{- end -}} +{{- end -}} + {{/* Find highest number of needed database connections to set DB_POOL variable */}} diff --git a/charts/mastodon/templates/deployment-sidekiq.yaml b/charts/mastodon/templates/deployment-sidekiq.yaml index 5072e59..adcbb50 100644 --- a/charts/mastodon/templates/deployment-sidekiq.yaml +++ b/charts/mastodon/templates/deployment-sidekiq.yaml @@ -83,7 +83,7 @@ spec: - configMapRef: name: {{ include "mastodon.fullname" $context }}-env - secretRef: - name: {{ template "mastodon.secretName" . }} + name: {{ template "mastodon.secretName" $context }} env: - name: "DB_PASS" valueFrom: