{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "grafana.serviceAccountName" . }}
  namespace: {{ .Release.Namespace }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
  {{- if .Values.serviceAccount.annotations }}
  annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }}
  {{- end }}
secrets:
  - name: {{ template "common.names.fullname" . }}-admin
  {{- if .Values.datasources.secretName }}
  - name: {{ .Values.datasources.secretName }}
  {{- end }}
  {{- if (include "grafana.createSMTPSecret" .) }}
  - name: {{ template "common.names.fullname" . }}-smtp
  {{- end }}
{{- end }}
