{{- if .Values.ingress.enabled }}
apiVersion: {{ template "odoo.ingress.apiVersion" . }}
kind: Ingress
metadata:
  name: {{ template "odoo.fullname" . }}
  labels:
    app: {{ template "odoo.name" . }}
    chart: {{ template "odoo.chart" . }}
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
  annotations:
    {{- if .Values.ingress.certManager }}
    kubernetes.io/tls-acme: "true"
    {{- end }}
    {{- range $key, $value := .Values.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  rules:
  {{- range .Values.ingress.hosts }}
  - host: {{ .name }}
    http:
      paths:
        - path: {{ default "/" .path }}
          backend:
            serviceName: {{ template "odoo.fullname" $ }}
            servicePort: http
  {{- end }}
  tls:
{{- range .Values.ingress.hosts }}
  - hosts:
{{- if .tls }}
    - {{ .name }}
    secretName: {{ .tlsSecret }}
{{- end }}
{{- end }}
{{- end }}
