{{- if .Values.clusterIssuer.enabled }}
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: {{ .Values.clusterIssuer.name }}
  labels:
    {{- include "cert-manager-stack.labels" . | nindent 4 }}
    app.kubernetes.io/component: issuer
  annotations:
    argocd.argoproj.io/sync-wave: "2"
spec:
  acme:
    # ACME server URL (Let's Encrypt)
    server: {{ .Values.clusterIssuer.server }}
    
    # Email address for ACME registration and expiration notifications
    email: {{ .Values.clusterIssuer.email }}
    
    # Name of the secret used to store the ACME account private key
    privateKeySecretRef:
      name: {{ .Values.clusterIssuer.privateKeySecretRef.name }}
    
    # DNS-01 challenge solver using Cloudflare
    solvers:
      - dns01:
          cloudflare:
            apiTokenSecretRef:
              name: {{ .Values.clusterIssuer.dns01.cloudflare.apiTokenSecretRef.name }}
              key: {{ .Values.clusterIssuer.dns01.cloudflare.apiTokenSecretRef.key }}
{{- end }}
