{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "external-dns.serviceAccountName" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "external-dns.labels" . | nindent 4 }}
  {{- with .Values.serviceAccount.labels }}
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- with .Values.serviceAccount.annotations }}
  annotations:
    {{- range $k, $v := . }}
      {{- printf "%s: %s" (toYaml (tpl $k $)) (toYaml (tpl $v $)) | nindent 4 }}
    {{- end }}
  {{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}
