-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_serviceAccounts.tpl
36 lines (33 loc) · 1.45 KB
/
_serviceAccounts.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{{- /*
Copyright 2024 New Vector Ltd
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
*/ -}}
{{- define "element-io.ess-library.serviceAccountName" -}}
{{- $root := .root -}}
{{- with required "element-io.ess-library.serviceAccountName missing context" .context -}}
{{ default (printf "%s-%s" $root.Release.Name (required "element-io.ess-library.serviceAccountName missing context.key" .key)) .serviceAccount.name }}
{{- end }}
{{- end }}
{{- define "element-io.ess-library.serviceAccount" -}}
{{- $root := .root -}}
{{- with required "element-io.ess-library.serviceAccount missing context" .context -}}
{{- $key := required "element-io.ess-library.serviceAccount missing context.key" .key -}}
{{- $extraAnnotations := .extraAnnotations | default dict -}}
{{- with required "element-io.ess-library.serviceAccount missing context.componentValues" .componentValues -}}
{{- if .serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- with (merge dict .serviceAccount.annotations $extraAnnotations) }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include (printf "element-io.%s.labels" $key) (dict "root" $root "context" .) | nindent 4 }}
name: {{ include "element-io.ess-library.serviceAccountName" (dict "root" $root "context" (dict "serviceAccount" .serviceAccount "key" $key)) }}
namespace: {{ $root.Release.Namespace }}
automountServiceAccountToken: false
{{- end }}
{{- end }}
{{- end }}
{{- end }}