1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-12 02:46:56 +00:00
kyverno/test/conformance/kuttl/policy-validation/cluster-policy/target-context/policy-1.yaml
shuting 4d5f832d01
fix mutate targets validation (#7387)
* fix mutate targets validation

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* linter fixes

Signed-off-by: ShutingZhao <shuting@nirmata.com>

---------

Signed-off-by: ShutingZhao <shuting@nirmata.com>
2023-06-02 15:06:01 +02:00

35 lines
830 B
YAML

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: update-targets
spec:
background: false
rules:
- name: update-targets
match:
any:
- resources:
kinds:
- ConfigMap
context:
- name: triggerContent
variable:
jmesPath: request.object.data.content
- name: targetContent
variable:
jmesPath: "{{target.data.content}}"
preconditions:
all:
- key: "{{ request.object.metadata.name }}"
operator: Equals
value: trigger
mutate:
targets:
- apiVersion: v1
kind: ConfigMap
namespace: "{{ request.object.metadata.namespace }}"
name: target*
patchStrategicMerge:
data:
content: "{{ triggerContent }}"
targetContent: "{{ targetContent }}"