{{ if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
metadata:
  name: {{ include "jenkins.serviceAccountName" . }}
  namespace: {{ template "jenkins.namespace" . }}
{{- if .Values.serviceAccount.annotations }}
  annotations:
{{ tpl (toYaml .Values.serviceAccount.annotations) . | indent 4 }}
{{- end }}
  labels:
    {{- include "jenkins.labels" . | nindent 4 }}
{{- if .Values.serviceAccount.extraLabels }}
{{ tpl (toYaml .Values.serviceAccount.extraLabels) . | indent 4 }}
{{- end }}
{{- if .Values.serviceAccount.imagePullSecretName }}
imagePullSecrets:
  - name: {{ .Values.serviceAccount.imagePullSecretName }}
{{- end -}}
{{ end }}
