From 6f178d6c03740954d41200b010c75cd1c705e900 Mon Sep 17 00:00:00 2001 From: Tim Campbell Date: Tue, 8 Apr 2025 16:03:14 +0200 Subject: [PATCH] Use coalesce for simplicity --- templates/cronjob-media-remove.yaml | 7 ++----- templates/deployment-sidekiq.yaml | 10 ++-------- templates/deployment-streaming.yaml | 7 ++----- templates/deployment-web.yaml | 7 ++----- templates/job-assets-copy.yaml | 7 ++----- templates/job-create-admin.yaml | 7 ++----- templates/job-db-migrate.yaml | 7 ++----- templates/job-db-pre-migrate.yaml | 7 ++----- templates/job-db-prepare.yaml | 7 ++----- 9 files changed, 18 insertions(+), 48 deletions(-) diff --git a/templates/cronjob-media-remove.yaml b/templates/cronjob-media-remove.yaml index 873fda0..a4c4510 100644 --- a/templates/cronjob-media-remove.yaml +++ b/templates/cronjob-media-remove.yaml @@ -107,11 +107,8 @@ spec: - name: system mountPath: /opt/mastodon/public/system {{- end }} - {{- if .Values.mastodon.cron.removeMedia.nodeSelector }} + {{- with coalesce .Values.mastodon.cron.removeMedia.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.cron.removeMedia.nodeSelector | toYaml | nindent 12 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 12 }} + {{- . | toYaml | nindent 12 }} {{- end }} {{- end }} diff --git a/templates/deployment-sidekiq.yaml b/templates/deployment-sidekiq.yaml index 6af7397..30ae0a5 100644 --- a/templates/deployment-sidekiq.yaml +++ b/templates/deployment-sidekiq.yaml @@ -258,15 +258,9 @@ spec: resources: {{- toYaml (default (default $context.Values.resources $context.Values.mastodon.sidekiq.resources) .resources) | nindent 12 }} {{- include "mastodon.statsdExporterContainer" $ | indent 8 }} - {{- if .nodeSelector }} + {{- with coalesce .nodeSelector $context.Values.mastodon.sidekiq.nodeSelector $context.Values.nodeSelector }} nodeSelector: - {{- .nodeSelector | toYaml | nindent 8 }} - {{- else if $context.Values.mastodon.sidekiq.nodeSelector }} - nodeSelector: - {{- $context.Values.mastodon.sidekiq.nodeSelector | toYaml | nindent 8 }} - {{- else if $context.Values.nodeSelector }} - nodeSelector: - {{- $context.Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- with $context.Values.tolerations }} tolerations: diff --git a/templates/deployment-streaming.yaml b/templates/deployment-streaming.yaml index 4d4c62c..b0752a4 100644 --- a/templates/deployment-streaming.yaml +++ b/templates/deployment-streaming.yaml @@ -164,12 +164,9 @@ spec: resources: {{- toYaml . | nindent 12 }} {{- end }} - {{- if .Values.mastodon.streaming.nodeSelector }} + {{- with coalesce .Values.mastodon.streaming.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.streaming.nodeSelector | toYaml | nindent 8 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- with (default .Values.affinity .Values.mastodon.streaming.affinity) }} affinity: diff --git a/templates/deployment-web.yaml b/templates/deployment-web.yaml index 29259c1..1031edf 100644 --- a/templates/deployment-web.yaml +++ b/templates/deployment-web.yaml @@ -272,12 +272,9 @@ spec: containerPort: {{ .Values.mastodon.metrics.prometheus.port }} {{- end }} {{- include "mastodon.statsdExporterContainer" $ | indent 8 }} - {{- if .Values.mastodon.web.nodeSelector }} + {{- with coalesce .Values.mastodon.web.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.web.nodeSelector | toYaml | nindent 8 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- with (default .Values.affinity .Values.mastodon.web.affinity) }} affinity: diff --git a/templates/job-assets-copy.yaml b/templates/job-assets-copy.yaml index 74d9fa9..496e599 100644 --- a/templates/job-assets-copy.yaml +++ b/templates/job-assets-copy.yaml @@ -89,12 +89,9 @@ spec: volumes: - name: assets emptyDir: {} - {{- if .Values.mastodon.hooks.s3Upload.nodeSelector }} + {{- with coalesce .Values.mastodon.hooks.s3Upload.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.hooks.s3Upload.nodeSelector | toYaml | nindent 8 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- end -}} diff --git a/templates/job-create-admin.yaml b/templates/job-create-admin.yaml index c1c671b..f54a696 100644 --- a/templates/job-create-admin.yaml +++ b/templates/job-create-admin.yaml @@ -95,11 +95,8 @@ spec: - name: system mountPath: /opt/mastodon/public/system {{- end }} - {{- if .Values.mastodon.createAdmin.nodeSelector }} + {{- with coalesce .Values.mastodon.createAdmin.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.createAdmin.nodeSelector | toYaml | nindent 8 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- end }} diff --git a/templates/job-db-migrate.yaml b/templates/job-db-migrate.yaml index d4839ee..c33d58d 100644 --- a/templates/job-db-migrate.yaml +++ b/templates/job-db-migrate.yaml @@ -1,10 +1,7 @@ {{- if .Values.mastodon.hooks.dbMigrate.enabled }} {{- include "mastodon.dbMigrateJob" (merge (dict "preDeploy" false ) .) }} - {{- if .Values.mastodon.hooks.dbMigrate.nodeSelector }} + {{- with coalesce .Values.mastodon.hooks.dbMigrate.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.hooks.dbMigrate.nodeSelector | toYaml | nindent 8 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- end }} diff --git a/templates/job-db-pre-migrate.yaml b/templates/job-db-pre-migrate.yaml index 8f87b5f..09b4759 100644 --- a/templates/job-db-pre-migrate.yaml +++ b/templates/job-db-pre-migrate.yaml @@ -1,10 +1,7 @@ {{- if .Values.mastodon.hooks.dbMigrate.enabled }} {{- include "mastodon.dbMigrateJob" (merge (dict "preDeploy" true ) .) }} - {{- if .Values.mastodon.hooks.dbMigrate.nodeSelector }} + {{- with coalesce .Values.mastodon.hooks.dbMigrate.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.hooks.dbMigrate.nodeSelector | toYaml | nindent 8 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- end }} diff --git a/templates/job-db-prepare.yaml b/templates/job-db-prepare.yaml index ca6324e..98fba59 100644 --- a/templates/job-db-prepare.yaml +++ b/templates/job-db-prepare.yaml @@ -1,10 +1,7 @@ {{- if and .Values.mastodon.hooks.dbPrepare.enabled (not .Values.postgresql.enabled) }} {{- include "mastodon.dbMigrateJob" (merge (dict "prepare" true ) .) }} - {{- if .Values.mastodon.hooks.dbPrepare.nodeSelector }} + {{- with coalesce .Values.mastodon.hooks.dbPrepare.nodeSelector .Values.nodeSelector }} nodeSelector: - {{- .Values.mastodon.hooks.dbPrepare.nodeSelector | toYaml | nindent 8 }} - {{- else if .Values.nodeSelector }} - nodeSelector: - {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- . | toYaml | nindent 8 }} {{- end }} {{- end }}