mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 16:37:04 +02:00
Co-authored-by: lab-assistant[bot] <180935599+lab-assistant[bot]@users.noreply.github.com>
41 lines
1.4 KiB
Smarty
41 lines
1.4 KiB
Smarty
{{- /*
|
|
Returns the value for the specified field
|
|
*/ -}}
|
|
{{- define "bjw-s.common.lib.pod.getOption" -}}
|
|
{{- $rootContext := .ctx.rootContext -}}
|
|
{{- $controllerObject := .ctx.controllerObject -}}
|
|
{{- $option := .option -}}
|
|
{{- $default := default "" .default -}}
|
|
{{- $value := $default -}}
|
|
|
|
{{- $defaultPodOptionsStrategy := dig "defaultPodOptionsStrategy" "overwrite" $rootContext.Values -}}
|
|
|
|
{{- /* Set to the default if it is set */ -}}
|
|
{{- $defaultOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}}
|
|
{{- if kindIs "bool" $defaultOption -}}
|
|
{{- $value = $defaultOption -}}
|
|
{{- else if not (empty $defaultOption) -}}
|
|
{{- $value = $defaultOption -}}
|
|
{{- end -}}
|
|
|
|
{{- /* See if a pod-specific override is needed */ -}}
|
|
{{- $podOption := dig $option nil (default dict $controllerObject.pod) -}}
|
|
|
|
{{- if kindIs "bool" $podOption -}}
|
|
{{- $value = $podOption -}}
|
|
{{- else if kindIs "map" $podOption -}}
|
|
{{- if eq "merge" $defaultPodOptionsStrategy -}}
|
|
{{- $value = merge $podOption $value -}}
|
|
{{- else if eq "overwrite" $defaultPodOptionsStrategy -}}
|
|
{{- $value = $podOption -}}
|
|
{{- end -}}
|
|
{{- else if not (empty $podOption) -}}
|
|
{{- $value = $podOption -}}
|
|
{{- end -}}
|
|
|
|
{{- if kindIs "bool" $value -}}
|
|
{{- $value | toYaml -}}
|
|
{{- else if not (empty $value) -}}
|
|
{{- $value | toYaml -}}
|
|
{{- end -}}
|
|
{{- end -}}
|