{{- if .Values.clusterissuerEnabled -}}
apiVersion: certmanager.k8s.io/v1alpha1
kind: ClusterIssuer
metadata:
  name: {{ .Values.ingressShim.defaultIssuerName }}
  labels:
    app: {{ template "cert-manager.name" . }}
    chart: {{ template "cert-manager.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  acme:
    {{- if eq .Values.ingressShim.defaultIssuerName "letsencrypt-prod" }}
    server: "https://acme-v02.api.letsencrypt.org/directory"
    {{- else if eq .Values.ingressShim.defaultIssuerName "letsencrypt-staging" }}
    server: "https://acme-staging-v02.api.letsencrypt.org/directory"
    {{- else }}
    server: {{ .Values.letsencrypt.server }}
    {{- end }}
    email: {{ .Values.letsencrypt.email }}
    privateKeySecretRef:
      name: {{ .Values.ingressShim.defaultIssuerName }}-account-key
    http01: {}
{{- end -}}
