{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{ if and .Values.features.apps .Values.serviceAccount.job.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "kube-arangodb.serviceAccountName" . }}-job
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/part-of: kube-arangodb
    app.kubernetes.io/component: operator
  {{- if or .Values.serviceAccount.job.annotations .Values.commonAnnotations }}
  {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceAccount.job.annotations .Values.commonAnnotations ) "context" . ) }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
  {{- end }}
{{- /* As the operator will create the job objects, it needs to have a SA that contains the image pull secrets */}}
{{- include "kube-arangodb.imagePullSecrets" . | nindent 2 }}
automountServiceAccountToken: {{ .Values.serviceAccount.job.automountServiceAccountToken }}
{{- end }}
