{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app: {{ template "docker-registry.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  namespace: {{ .Values.namespace | default .Release.Namespace }}
{{- if .Values.serviceAccount.name }}
  name: {{ .Values.serviceAccount.name }}
{{- else  }}
  name: {{ include "docker-registry.fullname" . }}
{{- end }}
{{- if .Values.serviceAccount.annotations }}
  annotations:
{{ toYaml .Values.serviceAccount.annotations | indent 4 }}
{{- end }}
{{- end -}}
