From 97b3b80818432fa3d505c1d409b41b233d5adbc9 Mon Sep 17 00:00:00 2001 From: Jan Welker Date: Mon, 21 Sep 2026 14:18:06 +0200 Subject: [PATCH] fix(nextcloud): mount defaultConfigs without requiring nextcloud.configs The config ConfigMap and its volume were only rendered when nextcloud.configs held at least one file. Every enabled nextcloud.defaultConfigs entry was therefore ignored on a default install. That silently broke nextcloud.openmetrics.allowedClients, whose only consumer is helm-metrics.config.php, and the documented imaginary.config.php setup. Neither file exists in the nextcloud image, so there is no fallback copy. Render and mount the ConfigMap whenever nextcloud.configs is non-empty or any defaultConfigs entry is enabled. Because the image entrypoint only seeds /var/www/html/config when it is empty, every enabled default mounts together, the same set that already mounted whenever nextcloud.configs was set. Fixes #887 Fixes #761 Signed-off-by: Jan Welker --- charts/nextcloud/Chart.yaml | 2 +- charts/nextcloud/README.md | 2 ++ charts/nextcloud/templates/_helpers.tpl | 15 +++++++++++++-- charts/nextcloud/templates/config.yaml | 4 ++-- charts/nextcloud/templates/cronjob.yaml | 2 +- charts/nextcloud/templates/deployment.yaml | 2 +- charts/nextcloud/values.yaml | 5 +++-- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/charts/nextcloud/Chart.yaml b/charts/nextcloud/Chart.yaml index f7b065f9..cd8cbc0f 100644 --- a/charts/nextcloud/Chart.yaml +++ b/charts/nextcloud/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: nextcloud -version: 9.3.0 +version: 9.3.1 # renovate: image=docker.io/library/nextcloud appVersion: 34.0.4 description: A file sharing server that puts the control and security of your own data back into your hands. diff --git a/charts/nextcloud/README.md b/charts/nextcloud/README.md index bd94bb23..8dd4aa31 100644 --- a/charts/nextcloud/README.md +++ b/charts/nextcloud/README.md @@ -165,6 +165,8 @@ The following table lists the configurable parameters of the nextcloud chart and | `nextcloud.defaultConfigs.smtp\.config\.php` | Default configuration for smtp | `true` | | `nextcloud.defaultConfigs.swift\.config\.php` | Default configuration for Swift as primary Object Storage | `true` | | `nextcloud.defaultConfigs.upgrade-disable-web\.config\.php` | Default config to disable the web-based updater as the default docker image does not suppor it | `true` | +| `nextcloud.defaultConfigs.helm-metrics\.config\.php` | Applies `nextcloud.openmetrics.allowedClients` to `openmetrics_allowed_clients` | `true` | +| `nextcloud.defaultConfigs.imaginary\.config\.php` | Preview configuration for the bundled Imaginary service | `false` | | `nextcloud.strategy` | specifies the strategy used to replace old Pods by new ones | `type: Recreate` | | `nextcloud.extraEnv` | specify additional environment variables | `{}` | | `nextcloud.extraSidecarContainers` | specify additional sidecar containers | `[]` | diff --git a/charts/nextcloud/templates/_helpers.tpl b/charts/nextcloud/templates/_helpers.tpl index 0b26c019..76ff1b40 100644 --- a/charts/nextcloud/templates/_helpers.tpl +++ b/charts/nextcloud/templates/_helpers.tpl @@ -392,6 +392,19 @@ Swift as primary object store env vars {{- end -}} +{{/* +Whether the config ConfigMap is rendered and mounted: true when nextcloud.configs +holds any file or any nextcloud.defaultConfigs entry is enabled. +Returns the string "true" or "false"; compare with (eq ... "true"). +*/}} +{{- define "nextcloud.configs.enabled" -}} +{{- $enabled := not (empty .Values.nextcloud.configs) -}} +{{- range $_, $on := .Values.nextcloud.defaultConfigs -}} +{{- if $on }}{{ $enabled = true }}{{ end -}} +{{- end -}} +{{- $enabled -}} +{{- end -}} + {{/* Create volume mounts for the nextcloud container as well as the cron sidecar container. */}} @@ -428,7 +441,6 @@ Create volume mounts for the nextcloud container as well as the cron sidecar con mountPath: /var/www/html/config/{{ $key }} subPath: {{ $key }} {{- end }} -{{- if .Values.nextcloud.configs }} {{- range $key, $value := .Values.nextcloud.defaultConfigs }} {{- if $value }} - name: nextcloud-config @@ -436,7 +448,6 @@ Create volume mounts for the nextcloud container as well as the cron sidecar con subPath: {{ $key }} {{- end }} {{- end }} -{{- end }} {{- if .Values.nextcloud.extraVolumeMounts }} {{ toYaml .Values.nextcloud.extraVolumeMounts }} {{- end }} diff --git a/charts/nextcloud/templates/config.yaml b/charts/nextcloud/templates/config.yaml index 8af94a3a..ba84e56a 100644 --- a/charts/nextcloud/templates/config.yaml +++ b/charts/nextcloud/templates/config.yaml @@ -1,4 +1,4 @@ -{{- if .Values.nextcloud.configs -}} +{{- if eq (include "nextcloud.configs.enabled" .) "true" -}} apiVersion: v1 kind: ConfigMap metadata: @@ -16,4 +16,4 @@ data: {{- tpl ($.Files.Get (printf "files/defaultConfigs/%s.tpl" $filename)) $ | nindent 4 }} {{- end }} {{- end }} -{{- end }}{{/* end-if configs */}} +{{- end }}{{/* end-if configs.enabled */}} diff --git a/charts/nextcloud/templates/cronjob.yaml b/charts/nextcloud/templates/cronjob.yaml index b0fa7d74..96f9f4ca 100644 --- a/charts/nextcloud/templates/cronjob.yaml +++ b/charts/nextcloud/templates/cronjob.yaml @@ -96,7 +96,7 @@ spec: persistentVolumeClaim: claimName: {{ if .Values.persistence.nextcloudData.existingClaim }}{{ .Values.persistence.nextcloudData.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud-data{{- end }} {{- end }} - {{- if .Values.nextcloud.configs }} + {{- if eq (include "nextcloud.configs.enabled" .) "true" }} - name: nextcloud-config configMap: name: {{ template "nextcloud.fullname" . }}-config diff --git a/charts/nextcloud/templates/deployment.yaml b/charts/nextcloud/templates/deployment.yaml index ab2ddc3e..d9ca31f7 100644 --- a/charts/nextcloud/templates/deployment.yaml +++ b/charts/nextcloud/templates/deployment.yaml @@ -382,7 +382,7 @@ spec: claimName: {{ with .Values.persistence.nextcloudData.existingClaim }}{{ . }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud-data{{- end }} {{- end }} {{- end }} - {{- if .Values.nextcloud.configs }} + {{- if eq (include "nextcloud.configs.enabled" .) "true" }} - name: nextcloud-config configMap: name: {{ template "nextcloud.fullname" . }}-config diff --git a/charts/nextcloud/values.yaml b/charts/nextcloud/values.yaml index 860ad7ad..36874497 100644 --- a/charts/nextcloud/values.yaml +++ b/charts/nextcloud/values.yaml @@ -244,8 +244,9 @@ nextcloud: phpConfigs: {} ## Default config files that utilize environment variables: # see: https://github.com/nextcloud/docker/tree/master#auto-configuration-via-environment-variables - # IMPORTANT: Will be used only if you put extra configs, otherwise default will come from nextcloud itself - # Default confgurations can be found here: https://github.com/nextcloud/docker/tree/master/.config + # Every enabled file is mounted into /var/www/html/config. Most mirror the files shipped in the + # nextcloud image; helm-metrics.config.php and imaginary.config.php exist only in this chart. + # Default configurations of the image can be found here: https://github.com/nextcloud/docker/tree/master/.config defaultConfigs: # To protect /var/www/html/config .htaccess: true