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