Preserve tpl for serversDefinitions
parent
6e638c0833
commit
4699c82b06
|
|
@ -25,4 +25,25 @@
|
|||
{{- $securityContext = omit $securityContext "appArmorProfile" -}}
|
||||
{{- end -}}
|
||||
{{- $securityContext | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "tpl.preserve.variable" -}}
|
||||
{{- $obj := . }}
|
||||
{{- if kindIs "map" $obj }}
|
||||
{{- range $k, $v := $obj }}
|
||||
{{- if kindIs "string" $v }}
|
||||
{{- if regexMatch "^[0-9]+$" $v }}
|
||||
{{- $_ := set $obj $k (atoi $v) }}
|
||||
{{- else if regexMatch "(?i)^(true|false)$" $v }}
|
||||
{{- $_ := set $obj $k (eq (lower $v) "true") }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- include "tpl.preserve.variable" $v }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if kindIs "slice" $obj }}
|
||||
{{- range $i, $v := $obj }}
|
||||
{{- include "tpl.preserve.variable" $v }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -10,5 +10,7 @@ metadata:
|
|||
annotations: {{ . | toYaml | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
servers.json: | {{ tpl (dict "Servers" .Values.serverDefinitions.data | toYaml) . | fromYaml | toPrettyJson | nindent 4 }}
|
||||
{{- $variableToPreserveTPL := tpl (dict "Servers" .Values.serverDefinitions.data | toYaml) . | fromYaml }}
|
||||
{{- include "tpl.preserve.variable" $variableToPreserveTPL }}
|
||||
servers.json: | {{ $variableToPreserveTPL | toYaml | nindent 4 }}
|
||||
{{- end }}
|
||||
Loading…
Reference in New Issue