{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ include "open-webui.name" . }}
  namespace: {{ include "open-webui.namespace" . }}
  labels:
    {{- include "open-webui.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- with .Values.ingress.class }}
  ingressClassName: {{ . }}
  {{- end }}
  {{- if .Values.ingress.tls }}
  tls:
    - hosts:
      - {{ .Values.ingress.host | quote }}
      {{- range .Values.ingress.additionalHosts }}
      - {{ . | quote }}
      {{- end }}
      secretName: {{ default (printf "%s-tls" .Release.Name) .Values.ingress.existingSecret }}
  {{- end }}
  rules:
  - host: {{ .Values.ingress.host }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: {{ include "open-webui.name" . }}
            port:
              name: http
  {{- range .Values.ingress.additionalHosts }}
  - host: {{ . | quote }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: {{ include "open-webui.name" $ }}
            port:
              name: http
  {{- end }}
{{- end }}
