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