{{- if .Values.webhooksServer.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: kargo-webhooks-server
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "kargo.labels" . | nindent 4 }}
    {{- include "kargo.webhooksServer.labels" . | nindent 4 }}
data:
  KARGO_NAMESPACE: {{ .Release.Namespace }}
  LOG_LEVEL: {{ quote .Values.webhooksServer.logLevel }}
  {{- if .Values.kubeconfigSecrets.kargo }}
  KUBECONFIG: /etc/kargo/kubeconfigs/kubeconfig.yaml
  {{- end }}
  {{- if .Values.webhooksServer.controlplaneUserRegex }}
  CONTROLPLANE_USER_REGEX: {{ .Values.webhooksServer.controlplaneUserRegex }}
  {{- else }}
  CONTROLPLANE_USER_REGEX: {{ include "kargo.controlplane.defaultUserRegex" . }}
  {{- end }}
{{- end }}
