apiVersion: v1
kind: Namespace
metadata:
  name: staging-2
  labels:
    app-type: corp
  annotations:
    cloud.platformzero.com/serviceClass: "xl2"
---
apiVersion: v1
data:
  foo: bar
kind: ConfigMap
metadata:
  name: dictionary-2
  namespace: staging-2
---
apiVersion: v1
data:
  foo: YmFy
kind: Secret
metadata:
  name: test-secret-2
  namespace: staging-2
type: Opaque
---
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: test-post-mutation-delete-trigger
spec:
  mutateExistingOnPolicyUpdate: false
  rules:
    - name: mutate-secret-on-configmap-delete
      match:
        any:
        - resources:
            kinds:
            - ConfigMap
            names:
            - dictionary-2
            namespaces:
            - staging-2
      preconditions:
        any:
        - key: "{{ request.operation }}"
          operator: Equals
          value: DELETE
      mutate:
        targets:
        - apiVersion: v1
          kind: Secret
          name: test-secret-2
          namespace: "{{ request.object.metadata.namespace }}"
        patchStrategicMerge:
          metadata:
            labels:
              foo: "{{ request.object.metadata.name }}"