From fe3a89ac706087cd6cf225236643d498cf03a8a6 Mon Sep 17 00:00:00 2001 From: Ben Banfield-Zanin Date: Wed, 13 Nov 2024 13:49:51 +0000 Subject: [PATCH] Specify server_name via globals --- charts/element-web/ci/checkov-values.yaml | 4 ++++ charts/element-web/ci/minimal-values.yaml | 4 ++++ charts/element-web/source/values.schema.json | 3 --- charts/element-web/source/values.yaml.j2 | 4 +--- charts/element-web/templates/_helpers.tpl | 2 +- charts/element-web/values.schema.json | 16 ++++++++++++---- charts/element-web/values.yaml | 11 ++++++++--- charts/matrix-stack/source/values.schema.json | 3 +++ charts/matrix-stack/source/values.yaml.j2 | 1 + charts/matrix-stack/sub_schemas/global.json | 13 ++++++++++++- .../sub_schemas/sub_schema_values.yaml.j2 | 11 +++++++++++ charts/matrix-stack/values.schema.json | 15 +++++++++++++++ charts/matrix-stack/values.yaml | 8 ++++++++ 13 files changed, 80 insertions(+), 15 deletions(-) diff --git a/charts/element-web/ci/checkov-values.yaml b/charts/element-web/ci/checkov-values.yaml index 2c99a6cf..2b927d8d 100644 --- a/charts/element-web/ci/checkov-values.yaml +++ b/charts/element-web/ci/checkov-values.yaml @@ -2,6 +2,10 @@ # # SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +global: + ess: + server_name: ess.localhost + defaultMatrixServer: baseUrl: https://synapse.ess.localhost diff --git a/charts/element-web/ci/minimal-values.yaml b/charts/element-web/ci/minimal-values.yaml index adf0e8a3..d6810a2a 100644 --- a/charts/element-web/ci/minimal-values.yaml +++ b/charts/element-web/ci/minimal-values.yaml @@ -2,6 +2,10 @@ # # SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +global: + ess: + server_name: ess.localhost + defaultMatrixServer: baseUrl: https://synapse.ess.localhost diff --git a/charts/element-web/source/values.schema.json b/charts/element-web/source/values.schema.json index 4b6acbf2..9a587326 100644 --- a/charts/element-web/source/values.schema.json +++ b/charts/element-web/source/values.schema.json @@ -20,9 +20,6 @@ "properties": { "baseUrl": { "type": "string" - }, - "serverName": { - "type": "string" } }, "type": "object" diff --git a/charts/element-web/source/values.yaml.j2 b/charts/element-web/source/values.yaml.j2 index f21c2bea..9bd8b872 100644 --- a/charts/element-web/source/values.yaml.j2 +++ b/charts/element-web/source/values.yaml.j2 @@ -5,6 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial #} {% import 'sub_schema_values.yaml.j2' as sub_schema_values -%} {{ sub_schema_values.generatedFileWarning() }} +{{ sub_schema_values.global() }} ## Arbitrary extra config to inject into Element Web's config.json a a YAML/JSON object additional: {} @@ -14,9 +15,6 @@ defaultMatrixServer: {} ## URL where the Matrix server is hosted # baseUrl: - ## Server name of the default Matrix server (if distinct from the baseUrl) - # serverName: - # Number of Element Web replicas to start up replicas: 2 {{ sub_schema_values.image(registry='docker.io', repository='vectorim/element-web') }} diff --git a/charts/element-web/templates/_helpers.tpl b/charts/element-web/templates/_helpers.tpl index 32e357ca..5e472763 100644 --- a/charts/element-web/templates/_helpers.tpl +++ b/charts/element-web/templates/_helpers.tpl @@ -12,8 +12,8 @@ app.kubernetes.io/version: {{ .Values.image.tag | default $.Chart.AppVersion }} {{- define "element-io.element-web.config" }} {{- $config := dict }} +{{- $serverName := required "Element Web requires global.ess.server_name set" .Values.global.ess.server_name }} {{- with .Values.defaultMatrixServer }} -{{- $serverName := .serverName | default .baseUrl }} {{- $mHomeserver := dict "base_url" .baseUrl "server_name" $serverName }} {{- $defaultServerConfig := dict "m.homeserver" $mHomeserver -}} {{- $_ := set $config "default_server_config" $defaultServerConfig }} diff --git a/charts/element-web/values.schema.json b/charts/element-web/values.schema.json index 71f5fe80..bbde56f7 100644 --- a/charts/element-web/values.schema.json +++ b/charts/element-web/values.schema.json @@ -21,9 +21,6 @@ "properties": { "baseUrl": { "type": "string" - }, - "serverName": { - "type": "string" } }, "type": "object", @@ -35,7 +32,18 @@ }, "global": { "type": "object", - "additionalProperties": false + "additionalProperties": true, + "properties": { + "ess": { + "type": "object", + "properties": { + "server_name": { + "type": "string" + } + }, + "additionalProperties": false + } + } }, "image": { "type": "object", diff --git a/charts/element-web/values.yaml b/charts/element-web/values.yaml index b2d2f870..2f56ed0c 100644 --- a/charts/element-web/values.yaml +++ b/charts/element-web/values.yaml @@ -4,6 +4,14 @@ # This file is generated. Do not edit directly. Edit source/values.yaml.j2 instead to make changes +## Global values available to all sub-charts +global: + ## ESS specific globals, namespaced to avoid interference with other charts + ess: {} + ## The server name of the Matrix Stack. This gets embedded in user IDs & room IDs + ## It can not change after the initial deployment. + # server_name: ess.localhost + ## Arbitrary extra config to inject into Element Web's config.json a a YAML/JSON object additional: {} @@ -12,9 +20,6 @@ defaultMatrixServer: {} ## URL where the Matrix server is hosted # baseUrl: - ## Server name of the default Matrix server (if distinct from the baseUrl) - # serverName: - # Number of Element Web replicas to start up replicas: 2 diff --git a/charts/matrix-stack/source/values.schema.json b/charts/matrix-stack/source/values.schema.json index b4f18660..3aee4c87 100644 --- a/charts/matrix-stack/source/values.schema.json +++ b/charts/matrix-stack/source/values.schema.json @@ -3,6 +3,9 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "global": { + "$ref": "file://./../../matrix-stack/sub_schemas/global.json" + }, "element-web": { "type": "object", "additionalProperties": true, diff --git a/charts/matrix-stack/source/values.yaml.j2 b/charts/matrix-stack/source/values.yaml.j2 index 01605d06..cf493cdf 100644 --- a/charts/matrix-stack/source/values.yaml.j2 +++ b/charts/matrix-stack/source/values.yaml.j2 @@ -5,6 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial #} {% import 'sub_schema_values.yaml.j2' as sub_schema_values -%} {{ sub_schema_values.generatedFileWarning() }} +{{ sub_schema_values.global() }} element-web: enabled: true diff --git a/charts/matrix-stack/sub_schemas/global.json b/charts/matrix-stack/sub_schemas/global.json index e6307dc1..41010dc0 100644 --- a/charts/matrix-stack/sub_schemas/global.json +++ b/charts/matrix-stack/sub_schemas/global.json @@ -1,3 +1,14 @@ { - "type": "object" + "type": "object", + "additionalProperties": true, + "properties": { + "ess": { + "type": "object", + "properties": { + "server_name": { + "type": "string" + } + } + } + } } diff --git a/charts/matrix-stack/sub_schemas/sub_schema_values.yaml.j2 b/charts/matrix-stack/sub_schemas/sub_schema_values.yaml.j2 index 4a538904..dfaaece1 100644 --- a/charts/matrix-stack/sub_schemas/sub_schema_values.yaml.j2 +++ b/charts/matrix-stack/sub_schemas/sub_schema_values.yaml.j2 @@ -8,6 +8,17 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial # This file is generated. Do not edit directly. Edit source/values.yaml.j2 instead to make changes {%- endmacro %} +{% macro global() %} +## Global values available to all sub-charts +global: + ## ESS specific globals, namespaced to avoid interference with other charts + ess: {} + ## The server name of the Matrix Stack. This gets embedded in user IDs & room IDs + ## It can not change after the initial deployment. + # server_name: ess.localhost + +{%- endmacro %} + {% macro containersSecurityContext(key='containersSecurityContext') %} ## A subset of SecurityContext. ContainersSecurityContext holds pod-level security attributes and common container settings {{ key }}: diff --git a/charts/matrix-stack/values.schema.json b/charts/matrix-stack/values.schema.json index d989a212..7614ac55 100644 --- a/charts/matrix-stack/values.schema.json +++ b/charts/matrix-stack/values.schema.json @@ -3,6 +3,21 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "global": { + "type": "object", + "additionalProperties": true, + "properties": { + "ess": { + "type": "object", + "properties": { + "server_name": { + "type": "string" + } + }, + "additionalProperties": false + } + } + }, "element-web": { "type": "object", "additionalProperties": true, diff --git a/charts/matrix-stack/values.yaml b/charts/matrix-stack/values.yaml index ab4572bb..4f8dabc4 100644 --- a/charts/matrix-stack/values.yaml +++ b/charts/matrix-stack/values.yaml @@ -4,5 +4,13 @@ # This file is generated. Do not edit directly. Edit source/values.yaml.j2 instead to make changes +## Global values available to all sub-charts +global: + ## ESS specific globals, namespaced to avoid interference with other charts + ess: {} + ## The server name of the Matrix Stack. This gets embedded in user IDs & room IDs + ## It can not change after the initial deployment. + # server_name: ess.localhost + element-web: enabled: true