{{- if not .Values.mail.ldap.server }}
{{- $fullName := include "emailleg.fullname" . -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
  name: {{ .Release.Name }}-correioadm
  labels:
    {{- include "emailleg.labels" . | nindent 4 }}
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  tls:
    - hosts:
        - "correioadm.{{ .Values.mail.domain }}"
      secretName: {{ .Release.Name }}-correioadm-crt
  rules:
    - host: "correioadm.{{ .Values.mail.domain }}"
      http:
        paths:
          - path: {{ .path }}
            {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
            pathType: ImplementationSpecific
            {{- end }}
            backend:
              {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
              service:
                name: {{ .Release.Name }}-mail
                port:
                  number: 80
              {{- else }}
              serviceName: {{ .Release.Name }}-mail
              servicePort: http
              {{- end }}
{{- end }}