Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / common / templates / _tplvalues.tpl
1 {{/*
2 # Copyright © Original (https://github.com/bitnami/charts) VMware, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16
17 {{/* vim: set filetype=mustache: */}}
18 {{/*
19 Renders a value that contains template perhaps with scope if the scope is present.
20 Usage:
21 {{ include "common.tplvalues._render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
22 {{ include "common.tplvalues._render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
23 */}}
24 {{- define "common.tplvalues._render" -}}
25 {{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
26 {{- if contains "{{" (toJson .value) }}
27   {{- if .scope }}
28       {{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
29   {{- else }}
30     {{- tpl $value .context }}
31   {{- end }}
32 {{- else }}
33     {{- $value }}
34 {{- end }}
35 {{- end -}}
36
37 {{/*
38 Merge a list of values that contains template after rendering them.
39 Merge precedence is consistent with http://masterminds.github.io/sprig/dicts.html#merge-mustmerge
40 Usage:
41 {{ include "common.tplvalues._merge" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
42 */}}
43 {{- define "common.tplvalues._merge" -}}
44 {{- $dst := dict -}}
45 {{- range .values -}}
46 {{- $dst = include "common.tplvalues._render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst -}}
47 {{- end -}}
48 {{ $dst | toYaml }}
49 {{- end -}}