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>
23 lines
910 B
Smarty
23 lines
910 B
Smarty
{{- /*
|
|
Returns the value for serviceAccountName
|
|
*/ -}}
|
|
{{- define "bjw-s.common.lib.pod.field.serviceAccountName" -}}
|
|
{{- $rootContext := .ctx.rootContext -}}
|
|
{{- $controllerObject := .ctx.controllerObject -}}
|
|
{{- $serviceAccountName := "default" -}}
|
|
|
|
{{- with $controllerObject.serviceAccount -}}
|
|
{{- if hasKey . "identifier" -}}
|
|
{{- $subject := (include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" .identifier) | fromYaml) -}}
|
|
|
|
{{- if not $subject }}
|
|
{{- fail (printf "No enabled ServiceAccount found with this identifier. (controller: '%s', identifier: '%s')" $controllerObject.identifier .identifier) -}}
|
|
{{- end -}}
|
|
|
|
{{- $serviceAccountName = get $subject "name" -}}
|
|
{{- else if hasKey . "name" -}}
|
|
{{- $serviceAccountName = .name -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $serviceAccountName -}}
|
|
{{- end -}}
|