Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / mongodb / common / templates / _tplvalues.tpl
1 {{/*
2 Copyright VMware, Inc.
3 SPDX-License-Identifier: APACHE-2.0
4 */}}
5
6 {{/* vim: set filetype=mustache: */}}
7 {{/*
8 Renders a value that contains template perhaps with scope if the scope is present.
9 Usage:
10 {{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
11 {{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
12 */}}
13 {{- define "common.tplvalues.render" -}}
14 {{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
15 {{- if contains "{{" (toJson .value) }}
16   {{- if .scope }}
17       {{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
18   {{- else }}
19     {{- tpl $value .context }}
20   {{- end }}
21 {{- else }}
22     {{- $value }}
23 {{- end }}
24 {{- end -}}
25
26 {{/*
27 Merge a list of values that contains template after rendering them.
28 Merge precedence is consistent with http://masterminds.github.io/sprig/dicts.html#merge-mustmerge
29 Usage:
30 {{ include "common.tplvalues.merge" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
31 */}}
32 {{- define "common.tplvalues.merge" -}}
33 {{- $dst := dict -}}
34 {{- range .values -}}
35 {{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst -}}
36 {{- end -}}
37 {{ $dst | toYaml }}
38 {{- end -}}