{{- if .Values.global.openshift }}
{{- if ne .mode "external" }}
{{- if and (.Values.server.route.enabled) (eq .Values.global.deploymentMode "development") -}}
{{- $serviceName := include "vault.fullname" . -}}
{{- if eq .mode "ha" }}
{{- $serviceName = printf "%s-%s" $serviceName "active" -}}
{{- end }}
kind: Route
apiVersion: route.openshift.io/v1
metadata:
  name: {{ template "vault.fullname" . }}
  labels:
    helm.sh/chart: {{ include "vault.chart" . }}
    app.kubernetes.io/name: {{ include "vault.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    {{- with .Values.server.route.labels }}
      {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- template "vault.route.annotations" . }}
spec:
  to:
    kind: Service
    name: {{ $serviceName }}
    weight: 100
  port:
    targetPort: 8200
  tls:
    termination: edge
    insecureEdgeTerminationPolicy: Redirect
  wildcardPolicy: None
{{- end }}
{{- end }}
{{- end }}
