{{- 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" . }}
  annotations:
    # Reference Let's Encrypt issuer directly
    kubernetes.io/tls-acme: "true"
    {{- if and (hasKey .Values "tls") (hasKey .Values.tls "enabled") .Values.tls.enabled (hasKey .Values.tls "secretName") }}
    # This annotation helps with certificate management
    route.openshift.io/tls-secret-name: {{ .Values.tls.secretName }}
    {{- end }}
spec:
  host: www.{{ .Values.ingress.host }}
  to:
    kind: Service
    name: {{ template "landing.name" . }}
    weight: 100
  port:
    targetPort: 8080
  # Always enable TLS for security
  tls:
    termination: edge
    insecureEdgeTerminationPolicy: Redirect
  wildcardPolicy: None
{{- end }} 