{{- if or (and $.Values.crds.exclusive $.Values.crds.createRBAC) (not $.Values.crds.exclusive) }}
  {{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "capsule.serviceAccountName" . }}
  namespace: {{ $.Release.Namespace }}
  labels:
    {{- include "capsule.labels" . | nindent 4 }}
    {{- if or (.Values.serviceAccount.annotations) (.Values.customAnnotations)  }}
  annotations:
      {{- include "capsule.serviceAccountAnnotations" . | nindent 4 }}
    {{- end }}
{{- with .Values.serviceAccount.imagePullSecrets }}
imagePullSecrets:
{{- range . }}
  - name: {{ . | quote }}
{{- end }}
{{- end }}
  {{- end }}
{{- end }}
