{{- include "nplus.init" $ -}}
{{- if ( include "nplus.ingressEnabled" . ) }}
{{- $provider := (.this.ingress).provider -}}
{{- if eq $provider "ingress" }}
{{- include "nplus.ingress" (list . .component.fullName) | nindent 0 }}
      - path: {{ .this.ingress.contextPath }}
        pathType: Prefix
        backend:
          service:
            name: {{ .component.fullName }}
            port: 
              name: {{ include "nplus.backendProtocol" . }}
      {{- if .Values.ingress.includeDefaultPaths }}
      - path: /index.html
        pathType: Exact
        backend:
          service:
            name: {{ .component.fullName }}
            port: 
              name: {{ include "nplus.backendProtocol" . }}
      - path: /res
        pathType: Prefix
        backend:
          service:
            name: {{ .component.fullName }}
            port: 
              name: {{ include "nplus.backendProtocol" . }}
      - path: /engine.properties
        pathType: Exact
        backend:
          service:
            name: {{ .component.fullName }}
            port: 
              name: {{ include "nplus.backendProtocol" . }}
      {{- end }}{{/* if .Values.ingress.includeDefaultPaths */}}
{{- else if eq $provider "gateway" }}
{{- include "nplus.gatewayRoute" (list . .component.fullName) | nindent 0 }}
  - matches:
    - path:
        type: PathPrefix
        value: {{ .this.ingress.contextPath }}
    {{- if .Values.ingress.includeDefaultPaths }}
    - path:
        type: Exact
        value: /index.html
    - path:
        type: PathPrefix
        value: /res
    - path:
        type: Exact
        value: /engine.properties
    {{- end }}{{/* if .Values.ingress.includeDefaultPaths */}}
    backendRefs:
    - name: {{ .component.fullName }}
      port: {{ include "nplus.backendPort" . }}
{{- else }}{{/* if provider */}}
{{- fail (printf "unsupported ingress provider: %s" $provider) -}}
{{- end }}{{/* if provider */}}
{{- else }}{{/* if ( include "nplus.ingressEnabled" . ) */}}
# kind: ingress
# Not Generating any Ingress for {{ .component.fullName }} as
# Ingress = {{ .this.ingress }}
# Service = {{ .this.service }}
{{- end }}{{/* if ( include "nplus.ingressEnabled" . ) else */}}
