{{- if and (hasKey .Values.ingress "enabled") .Values.ingress.enabled (hasKey .Values "tls") (hasKey .Values.tls "enabled") .Values.tls.enabled }}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: {{ .Values.tls.secretName }}
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ template "landing.name" . }}
spec:
  dnsNames:
    - {{ .Values.ingress.host }}
    {{- if and (hasKey .Values.ingress "www") (hasKey .Values.ingress.www "enabled") .Values.ingress.www.enabled }}
    - www.{{ .Values.ingress.host }}
    {{- end }}
  duration: {{ default "2160h" .Values.certificate.duration }}
  renewBefore: {{ default "720h" .Values.certificate.renewBefore }}
  issuerRef:
    kind: ClusterIssuer
    name: {{ default "letsencrypt-prod" .Values.certificate.issuer }}
  secretName: {{ .Values.tls.secretName }}
{{- end }} 