{{- if and .Values.ingressController.enabled .Values.ingressController.secretsNamespace.create .Values.ingressController.secretsNamespace.name }}
---
apiVersion: v1
kind: Namespace
metadata:
  name: {{ .Values.ingressController.secretsNamespace.name | quote }}
{{- end}}

# Only create the namespace if it's different from Ingress secret namespace or Ingress is not enabled.
{{- if and .Values.gatewayAPI.enabled .Values.gatewayAPI.secretsNamespace.create .Values.gatewayAPI.secretsNamespace.name
  (or (not (and .Values.ingressController.enabled .Values.ingressController.secretsNamespace.create .Values.ingressController.secretsNamespace.name))
      (ne .Values.gatewayAPI.secretsNamespace.name .Values.ingressController.secretsNamespace.name)) }}
---
apiVersion: v1
kind: Namespace
metadata:
  name: {{ .Values.gatewayAPI.secretsNamespace.name | quote }}
{{- end}}

# Only create the namespace if it's different from Ingress and Gateway API secret namespaces (if enabled).
{{- if and .Values.envoyConfig.enabled .Values.envoyConfig.secretsNamespace.create .Values.envoyConfig.secretsNamespace.name
  (and
    (or (not (and .Values.ingressController.enabled .Values.ingressController.secretsNamespace.create .Values.ingressController.secretsNamespace.name))
        (ne .Values.envoyConfig.secretsNamespace.name .Values.ingressController.secretsNamespace.name))
    (or (not (and .Values.gatewayAPI.enabled .Values.gatewayAPI.secretsNamespace.create .Values.gatewayAPI.secretsNamespace.name))
        (ne .Values.envoyConfig.secretsNamespace.name .Values.gatewayAPI.secretsNamespace.name))) }}
---
apiVersion: v1
kind: Namespace
metadata:
  name: {{ .Values.envoyConfig.secretsNamespace.name | quote }}
{{- end}}
