{{- if .Values.route.enabled -}}
{{- $serviceName := include "sonarqube.fullname" . -}}
kind: Route
apiVersion: route.openshift.io/v1
metadata:
  name: {{ template "sonarqube.fullname" . }}
  labels:
    app: {{ template "sonarqube.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
{{- if .Values.route.labels }}
{{ .Values.route.labels | toYaml | trimSuffix "\n"| indent 4 -}}
{{- end}}
{{- if .Values.route.annotations}}
  annotations:
    {{- range $key, $value := .Values.route.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
{{- end }}
spec:
{{- if .Values.route.host }}
  host: {{ .Values.route.host }}
{{- end }}
  to:
    kind: Service
    name: {{ default $serviceName .serviceName }}
  port:
    targetPort: http
  {{- if .Values.route.tls }}
  tls:
{{ toYaml .Values.route.tls | indent 4 }}
  {{- end -}}
{{- end -}}
