{% if 'ingress' == ingress_type|lower %}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: '{{ ansible_operator_meta.name }}-ingress'
  namespace: '{{ ansible_operator_meta.namespace }}'
{% if ingress_annotations %}
  annotations:
    {{ ingress_annotations | indent(width=4) }}
{% endif %}
spec:
  rules:
    - host: '{{ hostname }}'
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: '{{ ansible_operator_meta.name }}-web-svc'
                port:
                  number: 24880
{% if ingress_tls_secret %}
  tls:
    - hosts:
        - {{ hostname }}
      secretName: {{ ingress_tls_secret }}
{% endif %}
{% endif %}

{% if 'route' == ingress_type|lower %}
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: '{{ ansible_operator_meta.name }}'
  namespace: '{{ ansible_operator_meta.namespace }}'
spec:
{% if route_host != '' %}
  host: {{ route_host }}
{% endif %}
  port:
    targetPort: '{{ (route_tls_termination_mechanism | lower == "passthrough") | ternary("web-8443", "web-8080") }}'
  tls:
    insecureEdgeTerminationPolicy: Redirect
    termination: {{ route_tls_termination_mechanism | lower }}
{% if route_tls_termination_mechanism | lower == 'edge' and route_tls_secret != '' %}
    key: |-
{{ route_tls_key | indent(width=6, indentfirst=True) }}
    certificate: |-
{{ route_tls_crt | indent(width=6, indentfirst=True) }}
{% if route_ca_crt is defined %}
    caCertificate: |-
{{ route_ca_crt | indent(width=6, indentfirst=True) }}
{% endif %}
{% endif %}
  to:
    kind: Service
    name: {{ ansible_operator_meta.name }}-web-svc
    weight: 100
  wildcardPolicy: None
{% endif %}
