Skip to content

Commit 76fb3e4

Browse files
syn2mas: use new render-config helpers
1 parent 18439af commit 76fb3e4

7 files changed

Lines changed: 44 additions & 100 deletions

File tree

charts/matrix-stack/templates/ess-library/_render_config.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
99
{{- with required "element-io.ess-library.render-config-container missing context" .context -}}
1010
{{- $context := . -}}
1111
{{- $nameSuffix := required "element-io.ess-library.render-config-container missing context.nameSuffix" .nameSuffix -}}
12-
{{- $containerName := .containerName | default "render-config" -}}
12+
{{- $containerName := (.containerName | default "render-config") -}}
1313
{{- $additionalPath := .additionalPath -}}
1414
{{- $additionalProperty := dict -}}
1515
{{- if $additionalPath }}
@@ -18,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only
1818
{{- $outputFile := required "element-io.ess-library.render-config-container missing context.outputFile" .outputFile -}}
1919
{{- $underrides := .underrides | default list -}}
2020
{{- $overrides := required "element-io.ess-library.render-config-container missing context.overrides" .overrides -}}
21-
- name: {{ .containerName }}
21+
- name: {{ $containerName }}
2222
{{- with $root.Values.matrixTools.image -}}
2323
{{- if .digest }}
2424
image: "{{ .registry }}/{{ .repository }}@{{ .digest }}"

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,6 @@ app.kubernetes.io/version: {{ include "element-io.ess-library.labels.makeSafe" .
189189
{{- end }}
190190

191191

192-
{{- define "element-io.matrix-authentication-service.configmap-name" -}}
193-
{{- $root := .root -}}
194-
{{- $root.Release.Name }}-matrix-authentication-service
195-
{{- end }}
196-
197-
198192
{{- define "element-io.matrix-authentication-service.secret-name" }}
199193
{{- $root := .root }}
200194
{{- with required "element-io.matrix-authentication-service.secret-name requires context" .context }}
@@ -309,7 +303,7 @@ config.yaml: |
309303
{{ include "element-io.ess-library.render-config-container" (dict "root" $root "context" (
310304
dict "additionalPath" "matrixAuthenticationService.additional"
311305
"nameSuffix" "matrix-authentication-service"
312-
"containerName" .containerName
306+
"containerName" (.containerName | default "render-config")
313307
"overrides" (list "config.yaml")
314308
"outputFile" "config.yaml"
315309
"resources" .resources

charts/matrix-stack/templates/matrix-authentication-service/syn2mas_job.yaml

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -107,82 +107,8 @@ spec:
107107
volumeMounts:
108108
- mountPath: /tmp-mas-cli
109109
name: tmp-mas-cli
110-
- name: render-config-mas
111-
{{- with $.Values.matrixTools.image -}}
112-
{{- if .digest }}
113-
image: "{{ .registry }}/{{ .repository }}@{{ .digest }}"
114-
imagePullPolicy: {{ .pullPolicy | default "IfNotPresent" }}
115-
{{- else }}
116-
image: "{{ .registry }}/{{ .repository }}:{{ required "matrixTools.image.tag is required if no digest" .tag }}"
117-
imagePullPolicy: {{ .pullPolicy | default "Always" }}
118-
{{- end }}
119-
{{- end }}
120-
{{- with .containersSecurityContext }}
121-
securityContext:
122-
{{- toYaml . | nindent 10 }}
123-
{{- end }}
124-
command:
125-
{{- include "element-io.matrix-authentication-service.render-config" (dict "root" $ "context" $masContext) | nindent 8 }}
126-
env:
127-
{{- include "element-io.matrix-authentication-service.matrixToolsEnv" (dict "root" $ "context" $masContext) | nindent 8 }}
128-
{{- include "element-io.matrix-authentication-service.env" (dict "root" $ "context" $masContext) | nindent 8 }}
129-
{{- with .extraEnv }}
130-
{{- toYaml . | nindent 8 }}
131-
{{- end }}
132-
{{- with .resources }}
133-
resources:
134-
{{- toYaml . | nindent 10 }}
135-
{{- end }}
136-
volumeMounts:
137-
- mountPath: /config-templates
138-
name: plain-mas-config
139-
readOnly: true
140-
{{- range $secret := include "element-io.matrix-authentication-service.configSecrets" (dict "root" $ "context" $masContext) | fromJsonArray }}
141-
- mountPath: /secrets/{{ tpl $secret $ }}
142-
name: "secret-{{ tpl $secret $ }}"
143-
readOnly: true
144-
{{- end }}
145-
- mountPath: /conf
146-
name: rendered-config
147-
readOnly: false
148-
- name: render-config-syn
149-
{{- with $.Values.matrixTools.image -}}
150-
{{- if .digest }}
151-
image: "{{ .registry }}/{{ .repository }}@{{ .digest }}"
152-
imagePullPolicy: {{ .pullPolicy | default "IfNotPresent" }}
153-
{{- else }}
154-
image: "{{ .registry }}/{{ .repository }}:{{ required "matrixTools.image.tag is required if no digest" .tag }}"
155-
imagePullPolicy: {{ .pullPolicy | default "Always" }}
156-
{{- end }}
157-
{{- end }}
158-
{{- with .containersSecurityContext }}
159-
securityContext:
160-
{{- toYaml . | nindent 10 }}
161-
{{- end }}
162-
command:
163-
{{- include "element-io.synapse.render-config" (dict "root" $ "context" $synapseContext) | nindent 8 }}
164-
env:
165-
{{- include "element-io.synapse.matrixToolsEnv" (dict "root" $ "context" $synapseContext) | nindent 8 }}
166-
{{- include "element-io.synapse.env" (dict "root" $ "context" $synapseContext) | nindent 8 }}
167-
{{- with .extraEnv }}
168-
{{- toYaml . | nindent 8 }}
169-
{{- end }}
170-
{{- with .resources }}
171-
resources:
172-
{{- toYaml . | nindent 10 }}
173-
{{- end }}
174-
volumeMounts:
175-
- mountPath: /config-templates
176-
name: plain-syn-config
177-
readOnly: true
178-
{{- range $secret := include "element-io.synapse.configSecrets" (dict "root" $ "context" $synapseContext) | fromJsonArray }}
179-
- mountPath: /secrets/{{ tpl $secret $ }}
180-
name: "secret-{{ tpl $secret $ }}"
181-
readOnly: true
182-
{{- end }}
183-
- mountPath: /conf
184-
name: rendered-config
185-
readOnly: false
110+
{{- include "element-io.matrix-authentication-service.render-config-container" (dict "root" $ "context" $masContext) | nindent 6 }}
111+
{{- include "element-io.synapse.render-config-container" (dict "root" $ "context" $synapseContext) | nindent 6 }}
186112
- name: db-wait-mas
187113
{{- with $.Values.matrixTools.image -}}
188114
{{- if .digest }}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ path_map_file_get: |
245245
{{- include "element-io.ess-library.render-config-container" (dict "root" $root "context"
246246
(dict "additionalPath" "synapse.additional"
247247
"nameSuffix" "synapse"
248-
"containerName" .containerName
248+
"containerName" (.containerName | default "render-config")
249249
"underrides" (list "01-homeserver-underrides.yaml")
250250
"overrides" (list "04-homeserver-overrides.yaml"
251251
(eq $processType "check-config-hook" | ternary "05-main.yaml" (printf "05-%s.yaml" $processType)))

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,7 @@ We have an init container to render & merge the config for several reasons:
6060
* We could do this all in the main Synapse container but then there's potential confusion between `/config-templates`, `/conf` in the image and `/conf` the `emptyDir`
6161
*/}}
6262
initContainers:
63-
{{- include "element-io.ess-library.render-config-container" (dict "root" $root "context"
64-
(dict "additionalPath" "synapse.additional"
65-
"nameSuffix" "synapse"
66-
"underrides" (list "01-homeserver-underrides.yaml")
67-
"overrides" (list "04-homeserver-overrides.yaml"
68-
(eq $processType "check-config" | ternary "05-main.yaml" (printf "05-%s.yaml" $processType)))
69-
"outputFile" "homeserver.yaml"
70-
"resources" .resources
71-
"containersSecurityContext" .containersSecurityContext
72-
"extraEnv" .extraEnv
73-
"isHook" $isHook)) | nindent 4 }}
63+
{{- include "element-io.synapse.render-config-container" (dict "root" $root "context" .) | nindent 4 }}
7464
{{- if not $isHook }}
7565
- name: db-wait
7666
{{- with $root.Values.matrixTools.image -}}

charts/matrix-stack/values.schema.json

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,6 +3450,34 @@
34503450
"required": [
34513451
"repository"
34523452
],
3453+
"oneOf": [
3454+
{
3455+
"required": [
3456+
"tag",
3457+
"digest"
3458+
]
3459+
},
3460+
{
3461+
"required": [
3462+
"digest"
3463+
],
3464+
"not": {
3465+
"required": [
3466+
"tag"
3467+
]
3468+
}
3469+
},
3470+
{
3471+
"required": [
3472+
"tag"
3473+
],
3474+
"not": {
3475+
"required": [
3476+
"digest"
3477+
]
3478+
}
3479+
}
3480+
],
34533481
"properties": {
34543482
"registry": {
34553483
"type": "string"
@@ -3458,10 +3486,16 @@
34583486
"type": "string"
34593487
},
34603488
"tag": {
3461-
"type": "string"
3489+
"type": [
3490+
"string",
3491+
"null"
3492+
]
34623493
},
34633494
"digest": {
3464-
"type": "string"
3495+
"type": [
3496+
"string",
3497+
"null"
3498+
]
34653499
},
34663500
"pullPolicy": {
34673501
"type": "string",

tests/manifests/test_labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def test_templates_have_postgres_hash_label(release_name, templates, value
6767

6868
assert any(re.match("k8s.element.io/postgres-password-[a-z]+-hash", label) for label in labels), (
6969
f"{id} does not have postgres password hash label"
70-
) # We currently assume that Postgres is for top-level components only and so there is a single segment
70+
) # We currently assume that Postgres is for top-level components only and so there is a single segment
7171
# write (or read) path
7272
assert len(deployable_details.values_file_path.write_path) == 1
7373
helm_key = deployable_details.values_file_path.read_path[0]

0 commit comments

Comments
 (0)