# helm_charts_ingress-gateway.yaml
{{- if .Values.ingressGateway.enabled -}}
{{- $serviceName := include "ipfs.fullname" . -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  labels:
    app: {{ template "ipfs.name" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "ipfs.fullname" . }}-gateway
  annotations:
          {{- range $key, $value := .Values.ingressGateway.annotations }}
          {{ $key }}: {{ $value | quote }}
        {{- end }}
spec:
  rules:
          {{- range .Values.ingressGateway.hosts }}
          {{- $url := splitList "/" . }}
    - host: {{ first $url | quote }}
      http:
        paths:
          - path: /{{ rest $url | join "/" }}
            backend:
              serviceName: {{ $serviceName }}
              servicePort: 8080
        {{- end -}}
        {{- if .Values.ingressGateway.tls }}
  tls:
{{ toYaml .Values.ingressGateway.tls | indent 4 }}
        {{- end -}}
        {{- end -}}