From 63623c9fa1790cb30f04a7fa5b6a40609c25c490 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sat, 17 Jun 2023 14:45:25 +0300 Subject: [PATCH] fix(nextcloud): Correctly make use of accessIP when no ingress is enabled (#9720) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [x] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [x] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- charts/incubator/nextcloud/Chart.yaml | 2 +- charts/incubator/nextcloud/questions.yaml | 6 +--- .../nextcloud/templates/_configmap.tpl | 33 ++++++++++++------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/charts/incubator/nextcloud/Chart.yaml b/charts/incubator/nextcloud/Chart.yaml index 286aedbfbd0..dce908277b5 100644 --- a/charts/incubator/nextcloud/Chart.yaml +++ b/charts/incubator/nextcloud/Chart.yaml @@ -29,7 +29,7 @@ sources: - https://github.com/nextcloud/docker - https://github.com/nextcloud/helm type: application -version: 20.0.0 +version: 20.0.1 annotations: truecharts.org/catagories: | - cloud diff --git a/charts/incubator/nextcloud/questions.yaml b/charts/incubator/nextcloud/questions.yaml index 61747468991..d4826cc97a1 100644 --- a/charts/incubator/nextcloud/questions.yaml +++ b/charts/incubator/nextcloud/questions.yaml @@ -49,7 +49,7 @@ questions: type: dict attrs: - variable: run_optimize - label: Run Optiomize Scripts + label: Run Optimize Scripts description: | Runs the following commands at startup:
occ db:add-missing-indices
@@ -59,10 +59,6 @@ questions: occ maintenance:mimetype:update-js
occ maintenance:mimetype:update-db
occ maintenance:update:htaccess
- schema: - type: string - required: true - default: "" schema: type: boolean default: false diff --git a/charts/incubator/nextcloud/templates/_configmap.tpl b/charts/incubator/nextcloud/templates/_configmap.tpl index e23c7b4c210..5502964f450 100644 --- a/charts/incubator/nextcloud/templates/_configmap.tpl +++ b/charts/incubator/nextcloud/templates/_configmap.tpl @@ -1,8 +1,21 @@ {{/* Define the configmap */}} {{- define "nextcloud.configmaps" -}} {{- $fullname := (include "tc.v1.common.lib.chart.names.fullname" $) -}} -{{- $urlNoProtocol := regexReplaceAll ".*://(.*)" .Values.chartContext.APPURL "${1}" -}} -{{- $protocolOnly := regexReplaceAll "(.*)://.*" .Values.chartContext.APPURL "${1}" -}} +{{- $accessUrl := .Values.chartContext.APPURL -}} +{{- if or (contains "127.0.0.1" $accessUrl) (contains "localhost" $accessUrl) -}} + {{- if .Values.nextcloud.general.accessIP -}} + {{- $prot := "http" -}} + {{- $host := .Values.nextcloud.general.accessIP -}} + {{- $port := .Values.service.main.ports.main.port -}} + {{/* + Allowing here to override protocol and port + should be enough to make it work with any rev proxy + */}} + {{- $accessUrl = printf "%v://%v:%v" $prot $host $port -}} + {{- end -}} +{{- end -}} +{{- $accessHostPort := regexReplaceAll ".*://(.*)" $accessUrl "${1}" -}} +{{- $accessProtocol := regexReplaceAll "(.*)://.*" $accessUrl "${1}" -}} {{- $redisHost := .Values.redis.creds.plainhost | trimAll "\"" -}} {{- $redisPass := .Values.redis.creds.redisPassword | trimAll "\"" -}} {{- $healthHost := "kube.internal.healthcheck" -}} @@ -72,11 +85,7 @@ nextcloud-config: {{/* Notify Push */}} NX_NOTIFY_PUSH: {{ .Values.nextcloud.notify_push.enabled | quote }} {{- if .Values.nextcloud.notify_push.enabled }} - {{- $endpoint := .Values.chartContext.APPURL -}} - {{- if or (contains "127.0.0.1" $endpoint) (contains "localhost" $endpoint) -}} - {{- $endpoint = printf "http://%v:%v" $fullname .Values.service.main.ports.main.port -}} - {{- end }} - NX_NOTIFY_PUSH_ENDPOINT: {{ $endpoint }}/push + NX_NOTIFY_PUSH_ENDPOINT: {{ $accessUrl }}/push {{- end }} {{/* Previews */}} @@ -151,10 +160,10 @@ nextcloud-config: {{- end }} {{/* URLs */}} - NX_OVERWRITE_HOST: {{ $urlNoProtocol }} - NX_OVERWRITE_CLI_URL: {{ .Values.chartContext.APPURL }} + NX_OVERWRITE_HOST: {{ $accessHostPort }} + NX_OVERWRITE_CLI_URL: {{ $accessUrl }} # Return the protocol part of the URL - NX_OVERWRITE_PROTOCOL: {{ $protocolOnly | lower }} + NX_OVERWRITE_PROTOCOL: {{ $accessProtocol | lower }} # IP (or range in this case) of the proxy(ies) NX_TRUSTED_PROXIES: | {{ .Values.chartContext.svcCIDR }} @@ -166,8 +175,8 @@ nextcloud-config: {{ $fullname }} {{ printf "%v-*" $fullname }} {{ $healthHost }} - {{- if ne $urlNoProtocol "127.0.0.1" }} - {{- $urlNoProtocol | nindent 6 }} + {{- if not (contains "127.0.0.1" $accessHostPort) }} + {{- $accessHostPort | nindent 6 }} {{- end -}} {{- with .Values.nextcloud.general.accessIP }} {{- . | nindent 6 }}