{{- if and .Values.flowServer.enabled .Values.flowServer.httproute.enabled -}}
{{- if not .Values.flowServer.httproute.hostname }}
{{- fail "bp-openova-flow-server: .Values.flowServer.httproute.hostname is required when httproute.enabled=true" }}
{{- end }}
{{- if not .Values.flowServer.httproute.gatewayRef.name }}
{{- fail "bp-openova-flow-server: .Values.flowServer.httproute.gatewayRef.name is required when httproute.enabled=true" }}
{{- end }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: {{ include "bp-openova-flow-server.workloadName" . }}
  namespace: {{ .Release.Namespace }}
  labels: {{- include "bp-openova-flow-server.labels" . | nindent 4 }}
spec:
  parentRefs:
    - name: {{ .Values.flowServer.httproute.gatewayRef.name }}
      namespace: {{ .Values.flowServer.httproute.gatewayRef.namespace | default "kube-system" }}
  hostnames:
    - {{ .Values.flowServer.httproute.hostname | quote }}
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: {{ include "bp-openova-flow-server.workloadName" . }}
          port: {{ .Values.flowServer.service.port | default 80 }}
{{- end -}}
