Skip to content

Commit a03132a

Browse files
committed
Improve validation messages for values that are templated.
1 parent 4f0aafb commit a03132a

File tree

11 files changed

+129
-10
lines changed

11 files changed

+129
-10
lines changed

charts/matrix-stack/configs/matrix-authentication-service/config.yaml.tpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ database:
4242
{{- end }}
4343
{{- else if $root.Values.postgres.enabled }}
4444
uri: "postgresql://matrixauthenticationservice_user:${POSTGRES_PASSWORD}@{{ $root.Release.Name }}-postgres.{{ $root.Release.Namespace }}.svc.cluster.local:5432/matrixauthenticationservice?sslmode=prefer&application_name=matrix-authentication-service"
45-
{{ else }}
46-
{{ fail "MAS requires matrixAuthenticationService.postgres.* to be configured, or the internal chart Postgres to be enabled with postgres.enabled: true" }}
4745
{{ end }}
4846

4947
telemetry:

charts/matrix-stack/configs/synapse/synapse-04-homeserver-overrides.yaml.tpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
88
{{- with required "synapse/synapse-04-homeserver-overrides.yaml.tpl missing context" .context }}
99
{{- $isHook := required "element-io.synapse.config.shared-overrides requires context.isHook" .isHook -}}
1010
public_baseurl: https://{{ tpl .ingress.host $root }}/
11-
server_name: {{ tpl (required "Synapse requires serverName set" $root.Values.serverName) $root }}
11+
server_name: {{ tpl $root.Values.serverName $root }}
1212
signing_key_path: /secrets/{{
1313
include "element-io.ess-library.init-secret-path" (
1414
dict "root" $root "context" (
@@ -56,8 +56,6 @@ database:
5656
host: "{{ $root.Release.Name }}-postgres.{{ $root.Release.Namespace }}.svc.cluster.local"
5757
port: 5432
5858
sslmode: prefer
59-
{{ else }}
60-
{{ fail "Synapse requires synapse.postgres.* to be configured, or the internal chart Postgres to be enabled with postgres.enabled: true" }}
6159
{{ end }}
6260

6361
application_name: ${APPLICATION_NAME}

charts/matrix-stack/configs/well-known/partial-haproxy.cfg.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ frontend well-known-in
2424
{{ if .baseDomainRedirect.enabled }}
2525
{{- if $root.Values.elementWeb.enabled }}
2626
{{- with $root.Values.elementWeb }}
27-
{{- $elementWebHttps := include "element-io.ess-library.ingress.tlsHostsSecret" (dict "root" $root "context" (dict "hosts" (list (required "elementWeb.ingress.host is required" .ingress.host)) "tlsSecret" .ingress.tlsSecret "ingressName" "element-web")) }}
27+
{{- $elementWebHttps := include "element-io.ess-library.ingress.tlsHostsSecret" (dict "root" $root "context" (dict "hosts" (list .ingress.host) "tlsSecret" .ingress.tlsSecret "ingressName" "element-web")) }}
2828
http-request redirect code 301 location http{{ if $elementWebHttps }}s{{ end }}://{{ tpl .ingress.host $root }} unless well-known
2929
{{- end }}
3030
{{- else if .baseDomainRedirect.url }}

charts/matrix-stack/templates/element-web/_helpers.tpl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{{- /*
2-
Copyright 2024 New Vector Ltd
2+
Copyright 2024-2025 New Vector Ltd
33
44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
66

7+
{{- define "element-io.element-web.validations" }}
8+
{{- $root := .root -}}
9+
{{- with required "element-io.element-web.validations missing context" .context -}}
10+
{{ $messages := list }}
11+
{{- if not .ingress.host -}}
12+
{{ $messages = append $messages "elementWeb.ingress.host is required when elementWeb.enabled=true" }}
13+
{{- end }}
14+
{{ $messages | toJson }}
15+
{{- end }}
16+
{{- end }}
17+
718
{{- define "element-io.element-web.labels" -}}
819
{{- $root := .root -}}
920
{{- with required "element-io.element-web.labels missing context" .context -}}

charts/matrix-stack/templates/matrix-authentication-service/_helpers.tpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ Copyright 2025 New Vector Ltd
44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
66

7+
{{- define "element-io.matrix-authentication-service.validations" }}
8+
{{- $root := .root -}}
9+
{{- with required "element-io.matrix-authentication-service.validations missing context" .context -}}
10+
{{ $messages := list }}
11+
{{- if not .ingress.host -}}
12+
{{ $messages = append $messages "matrixAuthenticationService.ingress.host is required when matrixAuthenticationService.enabled=true" }}
13+
{{- end }}
14+
{{- if and (not $root.Values.postgres.enabled) (not .postgres) -}}
15+
{{ $messages = append $messages "matrixAuthenticationService.postgres is required when matrixAuthenticationService.enabled=true but postgres.enabled=false" }}
16+
{{- end }}
17+
{{ $messages | toJson }}
18+
{{- end }}
19+
{{- end }}
20+
721
{{- define "element-io.matrix-authentication-service.labels" -}}
822
{{- $root := .root -}}
923
{{- with required "element-io.matrix-authentication-service.labels missing context" .context -}}

charts/matrix-stack/templates/matrix-rtc/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ Copyright 2024-2025 New Vector Ltd
44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
66

7+
{{- define "element-io.matrix-rtc.validations" }}
8+
{{- $root := .root -}}
9+
{{- with required "element-io.matrix-rtc.validations missing context" .context -}}
10+
{{ $messages := list }}
11+
{{- if not .ingress.host -}}
12+
{{ $messages = append $messages "matrixRTC.ingress.host is required when matrixRTC.enabled=true" }}
13+
{{- end }}
14+
{{ $messages | toJson }}
15+
{{- end }}
16+
{{- end }}
17+
718
{{- define "element-io.matrix-rtc-ingress.labels" -}}
819
{{- $root := .root -}}
920
{{- with required "element-io.matrix-rtc.labels missing context" .context -}}

charts/matrix-stack/templates/synapse/_helpers.tpl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
{{- /*
2-
Copyright 2024 New Vector Ltd
2+
Copyright 2024-2025 New Vector Ltd
33
44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
66

7+
{{- define "element-io.synapse.validations" }}
8+
{{ $root := .root }}
9+
{{- with required "element-io.synapse.validations missing context" .context -}}
10+
{{ $messages := list }}
11+
{{- if not .ingress.host -}}
12+
{{ $messages = append $messages "synapse.ingress.host is required when synapse.enabled=true" }}
13+
{{- end }}
14+
{{- if not $root.Values.serverName -}}
15+
{{ $messages = append $messages "serverName is required when synapse.enabled=true" }}
16+
{{- end }}
17+
{{- if and (not $root.Values.postgres.enabled) (not .postgres) -}}
18+
{{ $messages = append $messages "synapse.postgres is required when synapse.enabled=true but postgres.enabled=false" }}
19+
{{- end }}
20+
{{ $messages | toJson }}
21+
{{- end }}
22+
{{- end }}
23+
724
{{- define "element-io.synapse.labels" -}}
825
{{- $root := .root -}}
926
{{- with required "element-io.synapse.labels missing context" .context -}}

charts/matrix-stack/templates/well-known/_helpers.tpl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{{- /*
2-
Copyright 2024 New Vector Ltd
2+
Copyright 2024-2025 New Vector Ltd
33
44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
66

7+
{{- define "element-io.well-known-delegation.validations" }}
8+
{{ $root := .root }}
9+
{{- with required "element-io.well-known-delegation.validations missing context" .context -}}
10+
{{- $messages := list }}
11+
{{- if not $root.Values.serverName -}}
12+
{{ $messages = append $messages "serverName is required when wellKnownDelegation.enabled=true" }}
13+
{{- end }}
14+
{{ $messages | toJson }}
15+
{{- end }}
16+
{{- end }}
17+
718
{{- define "element-io.well-known-delegation.labels" -}}
819
{{- $root := .root -}}
920
{{- with required "element-io.well-known-delegation.labels missing context" .context -}}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{ $messages := list }}
2+
3+
{{- with $.Values.elementWeb }}
4+
{{- if .enabled }}
5+
{{- $messages = concat $messages (include "element-io.element-web.validations" (dict "root" $ "context" .) | fromJsonArray) }}
6+
{{- end }}
7+
{{- end }}
8+
9+
{{- with $.Values.matrixAuthenticationService }}
10+
{{- if .enabled }}
11+
{{- $messages = concat $messages (include "element-io.matrix-authentication-service.validations" (dict "root" $ "context" .) | fromJsonArray) }}
12+
{{- end }}
13+
{{- end }}
14+
15+
{{- with $.Values.matrixRTC }}
16+
{{- if .enabled }}
17+
{{- $messages = concat $messages (include "element-io.matrix-rtc.validations" (dict "root" $ "context" .) | fromJsonArray) }}
18+
{{- end }}
19+
{{- end }}
20+
21+
{{- with $.Values.synapse }}
22+
{{- if .enabled }}
23+
{{- $messages = concat $messages (include "element-io.synapse.validations" (dict "root" $ "context" .) | fromJsonArray) }}
24+
{{- end }}
25+
{{- end }}
26+
27+
{{- with $.Values.wellKnownDelegation }}
28+
{{- if .enabled }}
29+
{{- $messages = concat $messages (include "element-io.well-known-delegation.validations" (dict "root" $ "context" .) | fromJsonArray) }}
30+
{{- end }}
31+
{{- end }}
32+
33+
{{- if gt (len $messages) 0 }}
34+
{{ fail ($messages | join "\n- " )}}
35+
{{- end }}

newsfragments/497.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve validation messages for values that are templated.

0 commit comments

Comments
 (0)