{{- include "nplus.init" $ -}}
{{- $name := (print .component.prefix "sharepoint-cluster") -}}
{{- if (.Values.clusterService).enabled }}
{{- if (.Values.clusterService).contextPath }}
{{- $provider := (.this.ingress).provider -}}
{{- if eq $provider "ingress" }}
{{- include "nplus.ingress" (list . $name) | nindent 0 }}
      - path: {{ .Values.clusterService.contextPath }}
        pathType: Prefix
        backend:
          service:
            name: {{ $name }}
            port: 
              name: {{ include "nplus.backendProtocol" . }}
{{- else if eq $provider "gateway" }}
{{- include "nplus.gatewayRoute" (list . $name) | nindent 0 }}
  - matches:
    - path:
        type: PathPrefix
        value: {{ .Values.clusterService.contextPath }}
    backendRefs:
    - name: {{ $name }}
      port: {{ include "nplus.backendPort" . }}
{{- else }}{{/* if provider */}}
{{- fail (printf "unsupported ingress provider: %s" $provider) -}}
{{- end }}{{/* if provider */}}
{{- else }}{{/* if (.Values.clusterService).contextPath */}}
# kind: Ingress
# Not Generating any Ingress for {{ $name }} as the context Path is unset on component {{ .component.fullName }}
# clusterService: {{ .Values.clusterService }}
{{- end }}{{/* if (.Values.clusterService).contextPath else */}}
{{- else }}{{/* if (.Values.clusterService).enabled */}}
# kind: Ingress
# Not Generating any Ingress for {{ $name }} as the Cluster Service is not enabled on component {{ .component.fullName }}
# clusterService: {{ .Values.clusterService }}
{{- end }}{{/* if (.Values.clusterService).enabled else */}}
