{{- if and .Values.hubble.ui.enabled .Values.hubble.ui.standalone.enabled .Values.hubble.relay.tls.server.enabled }}
{{- if not .Values.hubble.ui.standalone.tls.certsVolume }}
{{fail "Hubble UI in standalone with Hubble Relay server TLS enabled requires providing .Values.hubble.ui.standalone.tls.certsVolume for mounting client certificates in the backend pod" }}
{{- if not .Values.prometheus.serviceMonitor.trustCRDsExist }}
{{fail "Service Monitor requires monitoring.coreos.com/v1 CRDs. Please refer to https://github.com/prometheus-operator/prometheus-operator/blob/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml or set .Values.prometheus.serviceMonitor.trustCRDsExist=true" }}
{{- if or .Values.ingressController.enabled .Values.gatewayAPI.enabled (eq .Values.loadBalancer.l7.backend "envoy") }}
{{- if hasKey .Values "l7Proxy" }}
{{- if not .Values.l7Proxy }}
{{fail "Ingress or Gateway API controller or Envoy L7 Load Balancer requires .Values.l7Proxy to be set to 'true'" }}
{{- end }}
{{- end }}
{{- end }}
{{- if or .Values.envoyConfig.enabled .Values.ingressController.enabled .Values.gatewayAPI.enabled }}
{{- if or (eq (toString .Values.kubeProxyReplacement) "disabled") (and (not (hasKey .Values "kubeProxyReplacement")) (not (semverCompare ">=1.14" (default "1.14" .Values.upgradeCompatibility)))) }}
{{fail "Ingress/Gateway API controller and EnvoyConfig require .Values.kubeProxyReplacement to be explicitly set to 'false' or 'true'" }}
{{- end }}
{{- end }}
{{- if .Values.authentication.mutual.spire.enabled }}
{{- if not .Values.authentication.enabled }}
{{fail "SPIRE integration requires .Values.authentication.enabled=true and .Values.authentication.mutual.spire.enabled=true" }}
{{- end }}
{{- end }}
{{/* validate Cilium operator */}}
{{- if eq .Values.enableCiliumEndpointSlice true }}
{{- if eq .Values.disableEndpointCRD true }}
{{fail "if Cilium Endpoint Slice is enabled (.Values.enableCiliumEndpointSlice=true), it requires .Values.disableEndpointCRD=false" }}
{{- end }}
{{- end }}
{{/* validate clustermesh-apiserver */}}
{{- if .Values.clustermesh.useAPIServer }}
{{- if ne .Values.identityAllocationMode "crd" }}
{{fail (printf "The clustermesh-apiserver cannot be enabled in combination with .Values.identityAllocationMode=%s. To establish a Cluster Mesh, directly configure the parameters to access the remote kvstore through .Values.clustermesh.config" .Values.identityAllocationMode ) }}
{{- end }}
{{- if .Values.disableEndpointCRD }}
{{fail "The clustermesh-apiserver cannot be enabled in combination with .Values.disableEndpointCRD=true" }}
{{- end }}
{{- end }}
{{- if .Values.externalWorkloads.enabled }}
{{- if ne .Values.identityAllocationMode "crd" }}
{{fail (printf "External workloads support cannot be enabled in combination with .Values.identityAllocationMode=%s" .Values.identityAllocationMode ) }}
{{- end }}
{{- if .Values.disableEndpointCRD }}
{{fail "External workloads support cannot be enabled in combination with .Values.disableEndpointCRD=true" }}