Skip to content

Commit ff2fb32

Browse files
committed
Added support for string template rendering in the following properties:
- `extraEnvFrom` - `extraEnv` - `extraVolumes` - `extraVolumeMounts` - `extraVolumeClaimTemplates` - `extraInitContainers` - `extraContainerPorts` - `extraContainers`
1 parent 1341fe1 commit ff2fb32

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
- Updated to GraphDB [11.1.0](https://graphdb.ontotext.com/documentation/11.1/release-notes.html#graphdb-11-1-0)
88
- Updated the `extraObjects` template processing to additionally support rendering string Helm templates.
9+
- Added support for string template rendering in the following properties:
10+
- `extraEnvFrom`
11+
- `extraEnv`
12+
- `extraVolumes`
13+
- `extraVolumeMounts`
14+
- `extraVolumeClaimTemplates`
15+
- `extraInitContainers`
16+
- `extraContainerPorts`
17+
- `extraContainers`
918

1019
## Version 12.0.3
1120

templates/_helpers.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,23 @@ Calculate provisoner's bcrypt-hashed password
115115
{{- define "graphdb.security.provisioner.passwordHash" -}}
116116
{{- printf "%s" ( htpasswd .Values.security.provisioner.username .Values.security.provisioner.password | trimPrefix (printf "%s:" .Values.security.provisioner.username)) -}}
117117
{{- end -}}
118+
119+
{{/*
120+
Render string and yaml templates
121+
*/}}
122+
{{- define "render.list.singleMaps" -}}
123+
{{- $ctx := .ctx -}}
124+
{{- $items := .items | default (list) -}}
125+
{{- range $raw := $items }}
126+
{{- if kindIs "string" $raw -}}
127+
{{- $val := fromYamlArray (tpl $raw $ctx) -}}
128+
{{- if $val }}
129+
{{- toYaml $val | nindent 0 }}
130+
{{- end }}
131+
{{- else -}}
132+
{{- $m := fromYaml (tpl (toYaml $raw) $ctx ) -}}
133+
{{- $list := list $m -}}
134+
{{- toYaml $list | nindent 0 }}
135+
{{- end -}}
136+
{{ end }}
137+
{{- end -}}

templates/graphdb/statefulset.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spec:
4848
{{- toYaml .Values.import.volumeMount.volumeClaimTemplate.spec | nindent 8 }}
4949
{{- end }}
5050
{{- with .Values.extraVolumeClaimTemplates }}
51-
{{- tpl (toYaml .) $ | nindent 4 }}
51+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 4 }}
5252
{{- end }}
5353
{{- end }}
5454
template:
@@ -219,7 +219,7 @@ spec:
219219
{{- end }}
220220
{{- end }}
221221
{{- with .Values.extraVolumes }}
222-
{{- tpl (toYaml .) $ | nindent 8 }}
222+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 8 }}
223223
{{- end }}
224224
{{- with .Values.nodeSelector }}
225225
nodeSelector: {{- tpl (toYaml .) $ | nindent 8 }}
@@ -404,7 +404,7 @@ spec:
404404
405405
echo 'Done'
406406
{{- with .Values.extraInitContainers }}
407-
{{- tpl (toYaml .) $ | nindent 8 }}
407+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 8 }}
408408
{{- end }}
409409
containers:
410410
- name: {{ .Chart.Name }}
@@ -425,16 +425,17 @@ spec:
425425
containerPort: {{ .Values.containerPorts.rpc }}
426426
{{- end }}
427427
{{- with .Values.extraContainerPorts }}
428-
{{- toYaml . | nindent 12 }}
428+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
429429
{{- end }}
430430
envFrom:
431431
- configMapRef:
432432
name: {{ include "graphdb.fullname.configmap.environment" . }}
433433
{{- with .Values.extraEnvFrom }}
434-
{{- tpl (toYaml .) $ | nindent 12 }}
434+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
435435
{{- end }}
436436
{{- with .Values.extraEnv }}
437-
env: {{- tpl (toYaml .) $ | nindent 12 }}
437+
env:
438+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
438439
{{- end }}
439440
volumeMounts:
440441
- name: {{ .Values.persistence.volumeClaimTemplate.name }}
@@ -464,7 +465,7 @@ spec:
464465
mountPath: {{ .Values.cluster.tls.mountPath }}
465466
{{- end }}
466467
{{- with .Values.extraVolumeMounts }}
467-
{{- tpl (toYaml .) $ | nindent 12 }}
468+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
468469
{{- end }}
469470
{{- with .Values.resources }}
470471
resources: {{ toYaml . | nindent 12 }}
@@ -482,5 +483,5 @@ spec:
482483
livenessProbe: {{- toYaml . | nindent 12 }}
483484
{{- end }}
484485
{{- with .Values.extraContainers }}
485-
{{ tpl (toYaml .) $ | nindent 8 }}
486+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 8 }}
486487
{{- end }}

templates/proxy/statefulset.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
{{- toYaml .Values.proxy.persistence.volumeClaimTemplate.spec | nindent 8 }}
3838
{{- end }}
3939
{{- with .Values.proxy.extraVolumeClaimTemplates }}
40-
{{- tpl (toYaml .) $ | nindent 4 }}
40+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 4 }}
4141
{{- end }}
4242
{{- end }}
4343
template:
@@ -187,7 +187,7 @@ spec:
187187
{{- end }}
188188
{{- end }}
189189
{{- with .Values.proxy.extraVolumes }}
190-
{{- tpl (toYaml .) $ | nindent 8 }}
190+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 8 }}
191191
{{- end }}
192192
{{- with .Values.proxy.nodeSelector }}
193193
nodeSelector: {{- tpl (toYaml .) $ | nindent 8 }}
@@ -347,7 +347,7 @@ spec:
347347
348348
echo 'Done'
349349
{{- with .Values.proxy.extraInitContainers }}
350-
{{- toYaml . | nindent 8 }}
350+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 8 }}
351351
{{- end }}
352352
containers:
353353
- name: {{ include "graphdb-proxy.chartName" . }}
@@ -366,18 +366,19 @@ spec:
366366
- configMapRef:
367367
name: {{ include "graphdb-proxy.fullname.configmap.environment" . }}
368368
{{- with .Values.proxy.extraEnvFrom }}
369-
{{- tpl (toYaml .) $ | nindent 12 }}
369+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
370370
{{- end }}
371371
{{- with .Values.proxy.extraEnv }}
372-
env: {{- tpl (toYaml .) $ | nindent 12 }}
372+
env:
373+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
373374
{{- end }}
374375
ports:
375376
- name: http
376377
containerPort: {{ .Values.proxy.containerPorts.http }}
377378
- name: rpc
378379
containerPort: {{ .Values.proxy.containerPorts.rpc }}
379380
{{- with .Values.proxy.extraContainerPorts }}
380-
{{- toYaml . | nindent 12 }}
381+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
381382
{{- end }}
382383
volumeMounts:
383384
- name: {{ .Values.proxy.persistence.volumeClaimTemplate.name }}
@@ -396,7 +397,7 @@ spec:
396397
mountPath: {{ .Values.cluster.tls.mountPath }}
397398
{{- end }}
398399
{{- with .Values.proxy.extraVolumeMounts }}
399-
{{- toYaml . | nindent 12 }}
400+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 12 }}
400401
{{- end }}
401402
{{- with .Values.proxy.resources }}
402403
resources: {{ toYaml . | nindent 12 }}
@@ -414,6 +415,6 @@ spec:
414415
livenessProbe: {{- toYaml . | nindent 12 }}
415416
{{- end }}
416417
{{- with .Values.proxy.extraContainers }}
417-
{{ tpl (toYaml .) $ | nindent 8 }}
418+
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | indent 8 }}
418419
{{- end }}
419420
{{- end }}

0 commit comments

Comments
 (0)