diff --git a/content/en/docs/writing-policies/mutate.md b/content/en/docs/writing-policies/mutate.md index c84825ad9..154112c99 100644 --- a/content/en/docs/writing-policies/mutate.md +++ b/content/en/docs/writing-policies/mutate.md @@ -1168,7 +1168,7 @@ spec: secretName: mytlscertsecret ``` -This type of advanced mutation can be performed with nested foreach loops as shown below. Notice that in the JSON patch, the `path` value references the current index of `tls[]` as `{{elementIndex0}}` and the current index of `hosts[]` as `{{elementIndex1}}`. In the `value` field, the `{{element}}` variable still references the current value of the `hosts[]` array being processed. +This type of advanced mutation can be performed with nested foreach loops as shown below. Notice that in the JSON patch, the `path` value references the current index of `tls[]` as `{{elementIndex0}}` and the current index of `hosts[]` as `{{elementIndex1}}`. In the `value` field, the `{{element1}}` variable still references the current value of the `hosts[]` array being processed. ```yaml apiVersion: kyverno.io/v1 @@ -1187,12 +1187,14 @@ spec: mutate: foreach: - list: request.object.spec.tls[] + as: element0 foreach: - list: "element.hosts" + as: element1 patchesJson6902: |- - path: /spec/tls/{{elementIndex0}}/hosts/{{elementIndex1}} op: replace - value: "{{ replace_all('{{element}}', '.old.com', '.new.com') }}" + value: "{{ replace_all('{{element1}}', '.old.com', '.new.com') }}" ``` ## GitOps Considerations