ESS Library: unify ServiceAccount construction

This commit is contained in:
Ben Banfield-Zanin committed 2024-12-17 10:25:34 +00:00
1 parent a3aab79b9b
commit 9d035476a7
5 files changed
+27 -56

No files matched your search

@@ -5,19 +5,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
*/ -}}
{{- with .Values.elementWeb -}}
{{- if .enabled -}}
{{- if .serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- with .serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "element-io.element-web.labels" (dict "root" $ "context" .) | nindent 4 }}
name: {{ include "element-io.ess-library.serviceAccountName" (dict "root" $ "context" (dict "serviceAccount" .serviceAccount "key" "element-web")) }}
namespace: {{ $.Release.Namespace }}
automountServiceAccountToken: false
{{- end }}
{{- include "element-io.ess-library.serviceAccount" (dict "root" $ "context" (dict "componentValues" . "key" "element-web")) }}
{{- end }}
{{- end }}
@@ -10,3 +10,26 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
{{ default (printf "%s-%s" $root.Release.Name (required "element-io.ess-library.serviceAccount 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 -}}
{{- with required "element-io.ess-library.serviceAccount missing context.componentValues" .componentValues -}}
{{- if .serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- with .serviceAccount.annotations }}
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 }}
@@ -7,20 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
{{- with .Values.synapse -}}
{{- if .enabled -}}
{{- with .haproxy -}}
{{- if .serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- with .serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "element-io.synapse-haproxy.labels" (dict "root" $ "context" .) | nindent 4 }}
name: {{ include "element-io.ess-library.serviceAccountName" (dict "root" $ "context" (dict "serviceAccount" .serviceAccount "key" "synapse-haproxy")) }}
namespace: {{ $.Release.Namespace }}
automountServiceAccountToken: false
{{- end }}
{{- include "element-io.ess-library.serviceAccount" (dict "root" $ "context" (dict "componentValues" . "key" "synapse-haproxy")) }}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -8,20 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
{{- if .enabled -}}
{{- if (include "element-io.synapse.enabledWorkers" (dict "root" $)) | fromJson }}
{{- with .redis -}}
{{- if .serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- with .serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "element-io.synapse-redis.labels" (dict "root" $ "context" .) | nindent 4 }}
name: {{ include "element-io.ess-library.serviceAccountName" (dict "root" $ "context" (dict "serviceAccount" .serviceAccount "key" "synapse-redis")) }}
namespace: {{ $.Release.Namespace }}
automountServiceAccountToken: false
{{- end }}
{{- include "element-io.ess-library.serviceAccount" (dict "root" $ "context" (dict "componentValues" . "key" "synapse-redis")) }}
{{- end }}
{{- end -}}
{{- end -}}
@@ -6,19 +6,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
{{- with .Values.synapse -}}
{{- if .enabled -}}
{{- if .serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- with .serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "element-io.synapse.labels" (dict "root" $ "context" .) | nindent 4 }}
name: {{ include "element-io.ess-library.serviceAccountName" (dict "root" $ "context" (dict "serviceAccount" .serviceAccount "key" "synapse")) }}
namespace: {{ $.Release.Namespace }}
automountServiceAccountToken: false
{{- end }}
{{- include "element-io.ess-library.serviceAccount" (dict "root" $ "context" (dict "componentValues" . "key" "synapse")) }}
{{- end -}}
{{- end -}}