{{- if and .Values.forwarder.serviceAccount.create .Values.forwarder.enabled }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "fluentd.forwarder.serviceAccountName" . }}
  labels: {{- include "fluentd.labels" . | nindent 4 }}
    app.kubernetes.io/component: forwarder
  {{- if .Values.forwarder.serviceAccount.annotations }}
  annotations: {{- include "fluentd.tplValue" (dict "value" .Values.forwarder.serviceAccount.annotations "context" $) | nindent 4 }}
  {{- end }}
{{- end -}}
{{- if and .Values.aggregator.serviceAccount.create .Values.aggregator.enabled }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "fluentd.aggregator.serviceAccountName" . }}
  labels: {{- include "fluentd.labels" . | nindent 4 }}
    app.kubernetes.io/component: aggregator
  {{- if .Values.aggregator.serviceAccount.annotations }}
  annotations: {{- include "fluentd.tplValue" (dict "value" .Values.aggregator.serviceAccount.annotations "context" $) | nindent 4 }}
  {{- end }}
{{- end -}}
