kyverno(kube): foreach patchStrategicMerge must be inline mapping, not block scalar

This commit is contained in:
2026-09-09 23:07:13 +02:00
parent 764a029c39
commit 3d258f147d
@@ -88,9 +88,12 @@ spec:
# `request.object` is available in BOTH admission and background modes: # `request.object` is available in BOTH admission and background modes:
# the backgroundController synthesizes an admission-like request for # the backgroundController synthesizes an admission-like request for
# existing resources, so the same foreach works for both. # existing resources, so the same foreach works for both.
# NOTE: inside `foreach`, patchStrategicMerge must be an INLINE YAML
# mapping — a `|` block scalar is parsed as a string and fails with
# "wrong node kind: expected MappingNode but got ScalarNode".
foreach: foreach:
- list: "request.object.spec.containers" - list: "request.object.spec.containers"
patchStrategicMerge: | patchStrategicMerge:
spec: spec:
containers: containers:
- name: "{{ element.name }}" - name: "{{ element.name }}"
@@ -98,7 +101,7 @@ spec:
requests: requests:
cpu: null cpu: null
- list: "request.object.spec.initContainers || `[]`" - list: "request.object.spec.initContainers || `[]`"
patchStrategicMerge: | patchStrategicMerge:
spec: spec:
initContainers: initContainers:
- name: "{{ element.name }}" - name: "{{ element.name }}"