{{- if $.Values.oneuptimeIngress.enabled }}

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ printf "%s-%s" $.Release.Name "ingress"  }}
  namespace: {{ $.Release.Namespace }}
  labels:
    app: {{ printf "%s-%s" $.Release.Name "ingress"  }}
    app.kubernetes.io/part-of: oneuptime
    app.kubernetes.io/managed-by: Helm
    appname: oneuptime
  annotations: {{- $.Values.oneuptimeIngress.annotations | toYaml | nindent 4 }}
spec:
  ingressClassName: {{ $.Values.oneuptimeIngress.className }}
  {{- if $.Values.oneuptimeIngress.tls.enabled }}
  tls:
    {{- range $key, $val := $.Values.oneuptimeIngress.tls.hosts }}
    - hosts:
        - {{ $val.host }}
      secretName: {{ $val.secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- range $key, $val := $.Values.oneuptimeIngress.hosts }}
    - host: {{ $val }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: {{ printf "%s-%s" $.Release.Name "nginx"  }}
                port:
                  name: "http"
    {{- end }}
{{- end }}