{{- if and (hasKey .Values.ingress "www") (hasKey .Values.ingress.www "enabled") .Values.ingress.www.enabled }}
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: {{ template "landing.routename" . }}-www
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ template "landing.name" . }}
  {{- if and (hasKey .Values "tls") (hasKey .Values.tls "enabled") .Values.tls.enabled (hasKey .Values.tls "secretName") }}
  annotations:
    cert-manager.io/certificate-name: {{ .Values.tls.secretName }}
    route.openshift.io/termination: edge
  {{- end }}
spec:
  host: www.{{ .Values.ingress.host }}
  to:
    kind: Service
    name: {{ template "landing.name" . }}
  port:
    targetPort: 8080
  tls:
    termination: edge
    insecureEdgeTerminationPolicy: Redirect
    {{- if and (hasKey .Values "tls") (hasKey .Values.tls "enabled") .Values.tls.enabled (hasKey .Values.tls "secretName") }}
    # Use the secret name directly in the route so OpenShift knows which certificate to use
    destinationCACertificate: ""
    {{- end }}
{{- end }} 