Commit ae0cbbe 1 parent e8030ae commit ae0cbbe Copy full SHA for ae0cbbe
File tree 1 file changed +28
-2
lines changed
content/en/docs/writing-policies
1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1187,15 +1187,41 @@ spec:
1187
1187
mutate:
1188
1188
foreach:
1189
1189
- list: request.object.spec.tls[]
1190
- as: element0
1190
+ as: element0 # Outer loop element (tls array)
1191
1191
foreach:
1192
1192
- list: "element.hosts"
1193
- as: element1
1193
+ as: element1 # Inner loop element (hosts array)
1194
1194
patchesJson6902: |-
1195
1195
- path: /spec/tls/{{elementIndex0}}/hosts/{{elementIndex1}}
1196
1196
op: replace
1197
1197
value: "{{ replace_all('{{element1}}', '.old.com', '.new.com') }}"
1198
1198
` ` `
1199
+ For older Kyverno versions that do not support as:, elements can be accessed directly using {{element0}} and {{element1}}.
1200
+
1201
+ ` ` ` yaml
1202
+ apiVersion: kyverno.io/v1
1203
+ kind: ClusterPolicy
1204
+ metadata:
1205
+ name: replace-dns-suffix-legacy
1206
+ spec:
1207
+ background: false
1208
+ rules:
1209
+ - name: replace-dns-suffix
1210
+ match:
1211
+ any:
1212
+ - resources:
1213
+ kinds:
1214
+ - Ingress
1215
+ mutate:
1216
+ foreach:
1217
+ - list: request.object.spec.tls[]
1218
+ foreach:
1219
+ - list: element.hosts
1220
+ patchesJson6902: |-
1221
+ - path: /spec/tls/{{elementIndex0}}/hosts/{{elementIndex1}}
1222
+ op: replace
1223
+ value: "{{ replace_all('{{element}}', '.old.com', '.new.com') }}"
1224
+ ` ` `
1199
1225
1200
1226
# # GitOps Considerations
1201
1227
You can’t perform that action at this time.
0 commit comments