From 7d96109467f2b982b4c20b2c270128429f3c21cd Mon Sep 17 00:00:00 2001
From: jessebot <jessebot@linux.com>
Date: Thu, 25 Jul 2024 19:21:34 +0200
Subject: [PATCH] add nextcloud.trustedDomains helm paramter

Adding this directly helps with setting multiple values via helm parameters, instead of needing to pass in a whole config file.

Signed-off-by: jessebot <jessebot@linux.com>
---
 charts/nextcloud/Chart.yaml             | 2 +-
 charts/nextcloud/README.md              | 1 +
 charts/nextcloud/templates/_helpers.tpl | 4 ++++
 charts/nextcloud/values.yaml            | 2 ++
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/charts/nextcloud/Chart.yaml b/charts/nextcloud/Chart.yaml
index f79c4b29..ec72c02c 100644
--- a/charts/nextcloud/Chart.yaml
+++ b/charts/nextcloud/Chart.yaml
@@ -1,6 +1,6 @@
 apiVersion: v2
 name: nextcloud
-version: 5.3.2
+version: 5.4.0
 appVersion: 29.0.4
 description: A file sharing server that puts the control and security of your own data back into your hands.
 keywords:
diff --git a/charts/nextcloud/README.md b/charts/nextcloud/README.md
index 0f825076..e31284f1 100644
--- a/charts/nextcloud/README.md
+++ b/charts/nextcloud/README.md
@@ -120,6 +120,7 @@ The following table lists the configurable parameters of the nextcloud chart and
 | `nextcloud.existingSecret.smtpHostKey`                      | Name of the key that contains the SMTP hostname                                                     | `nil`                      |
 | `nextcloud.update`                                          | Trigger update if custom command is used                                                            | `0`                        |
 | `nextcloud.containerPort`                                   | Customize container port when not running as root                                                   | `80`                       |
+| `nextcloud.trustedDomains`                                  | Optional space-separated list of trusted domains                                                    | `[]`                       |
 | `nextcloud.datadir`                                         | nextcloud data dir location                                                                         | `/var/www/html/data`       |
 | `nextcloud.mail.enabled`                                    | Whether to enable/disable email settings                                                            | `false`                    |
 | `nextcloud.mail.fromAddress`                                | nextcloud mail send from field                                                                      | `nil`                      |
diff --git a/charts/nextcloud/templates/_helpers.tpl b/charts/nextcloud/templates/_helpers.tpl
index ca776947..b0bf7355 100644
--- a/charts/nextcloud/templates/_helpers.tpl
+++ b/charts/nextcloud/templates/_helpers.tpl
@@ -178,7 +178,11 @@ Create environment variables used to configure the nextcloud container as well a
       name: {{ .Values.nextcloud.existingSecret.secretName | default (include "nextcloud.fullname" .) }}
       key: {{ .Values.nextcloud.existingSecret.passwordKey }}
 - name: NEXTCLOUD_TRUSTED_DOMAINS
+  {{- if .Values.nextcloud.trustedDomains }}
+  value: {{ join " " .Values.nextcloud.trustedDomains | quote }}
+  {{- else }}
   value: {{ .Values.nextcloud.host }}{{ if .Values.metrics.enabled }} {{ template "nextcloud.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local{{ end }}
+  {{- end }}
 {{- if ne (int .Values.nextcloud.update) 0 }}
 - name: NEXTCLOUD_UPDATE
   value: {{ .Values.nextcloud.update | quote }}
diff --git a/charts/nextcloud/values.yaml b/charts/nextcloud/values.yaml
index e6eec271..2d2d5d40 100644
--- a/charts/nextcloud/values.yaml
+++ b/charts/nextcloud/values.yaml
@@ -93,6 +93,8 @@ nextcloud:
   datadir: /var/www/html/data
   persistence:
     subPath:
+  # if set, we'll template this list to the NEXTCLOUD_TRUSTED_DOMAINS env var
+  trustedDomains: []
   ## SMTP configuration
   mail:
     enabled: false