{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}  
{{- $issuerType := (index $cozyConfig.data "clusterissuer") | default "http01" }}  

apiVersion: cert-manager.io/v1 
kind: ClusterIssuer  
metadata:  
  name: letsencrypt-prod  
spec:  
  acme:  
    privateKeySecretRef:  
      name: letsencrypt-prod  
    server: https://acme-v02.api.letsencrypt.org/directory  
    solvers:  
    - {{- if eq $issuerType "cloudflare" }}  
        dns01:  
          cloudflare:  
            apiTokenSecretRef:  
              name: cloudflare-api-token-secret  
              key: api-token  
      {{- else }}  
        http01:  
          ingress:  
            class: nginx  
      {{- end }}  

---  

apiVersion: cert-manager.io/v1  
kind: ClusterIssuer  
metadata:  
  name: letsencrypt-stage  
spec:  
  acme:  
    privateKeySecretRef:  
      name: letsencrypt-stage
    server: https://acme-staging-v02.api.letsencrypt.org/directory  
    solvers:  
    - {{- if eq $issuerType "cloudflare" }}  
        dns01:  
          cloudflare:  
            apiTokenSecretRef:  
              name: cloudflare-api-token-secret  
              key: api-token  
      {{- else }}  
        http01:  
          ingress:  
            class: nginx  
      {{- end }}  

---  

apiVersion: cert-manager.io/v1  
kind: ClusterIssuer  
metadata:  
  name: selfsigned-cluster-issuer  
spec:  
  selfSigned: {}
