{{- if .Values.clusterConfig.kyverno.enabled }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  annotations:
    policies.clusterConfig.kyverno.io/category: Sample
    policies.clusterConfig.kyverno.io/description: 'Access dataprotection keys from Azure Key Vault'
  creationTimestamp: "2024-01-15T11:58:24Z"
  name: sync-keyvault-secrets
spec:
  admission: true
  background: true
  generateExisting: true
  rules:
  - generate:
      apiVersion: v1
      clone:
        name: azure-keyvault
        namespace: atlantis
      kind: Secret
      name: azure-keyvault
      namespace: '{{`{{request.object.metadata.name}}`}}'
      synchronize: true
    match:
      any:
      - resources:
          kinds:
          - Namespace
          names:
          - "*-atlantis"
    name: sync-keyvault-secrets
    skipBackgroundRequests: true
{{- end }}
