{{- if .Values.clusterConfig.kyverno.enabled }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: fixup-dapr-crds
spec:
  background: false
  generateExisting: false
  mutateExistingOnPolicyUpdate: false
  rules:
    - name: fix-subscriptions-webhook-namespace
      skipBackgroundRequests: true
      match:
        any:
        - resources:
            kinds:
            - CustomResourceDefinition
            names:
            - subscriptions.dapr.io
      mutate:
        patchStrategicMerge:
          spec:
            conversion:
              webhook:
                clientConfig:
                  service:
                    namespace: dapr-system
{{- end }}
