{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.certgen.serviceAccount.create .Values.certgen.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "envoy-gateway.certgen.serviceAccountName" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  {{- $labels := include "common.tplvalues.merge" ( dict "values" (list .Values.commonLabels .Values.certgen.labels) "context" . ) }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
    app.kubernetes.io/part-of: envoy-gateway
    app.kubernetes.io/component: certgen
  {{- if or .Values.certgen.annotations .Values.certgen.serviceAccount.annotations .Values.commonAnnotations }}
  annotations:
    {{- $mergedAnnotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.certgen.annotations .Values.certgen.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
    {{- include "common.tplvalues.render" ( dict "value" $mergedAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
automountServiceAccountToken: {{ .Values.certgen.serviceAccount.automountServiceAccountToken }}
{{- end }}
