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