mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 10:55:05 +00:00
parent
a243b405d2
commit
e75c766acd
6 changed files with 82 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: foreach-patchstrategicmerge-context-ns
|
||||
---
|
||||
apiVersion: v1
|
||||
data:
|
||||
image: nginx
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: foreach-patchstrategicmerge-context-configmap
|
||||
namespace: foreach-patchstrategicmerge-context-ns
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: foreach-patchstrategicmerge-context-policy
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,32 @@
|
|||
apiVersion : kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: foreach-patchstrategicmerge-context-policy
|
||||
spec:
|
||||
background: false
|
||||
rules:
|
||||
- name: resolve-image-containers
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- Pod
|
||||
preconditions:
|
||||
all:
|
||||
- key: "{{request.operation}}"
|
||||
operator: In
|
||||
value:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
mutate:
|
||||
foreach:
|
||||
- list: "request.object.spec.containers"
|
||||
context:
|
||||
- name: dictionary
|
||||
configMap:
|
||||
name: foreach-patchstrategicmerge-context-configmap
|
||||
namespace: foreach-patchstrategicmerge-context-ns
|
||||
patchStrategicMerge:
|
||||
spec:
|
||||
containers:
|
||||
- name: "{{ element.name }}"
|
||||
image: "{{ dictionary.data.image }}"
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: foreach-patchstrategicmerge-context-pod
|
||||
namespace: foreach-patchstrategicmerge-context-ns
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: foreach-patchstrategicmerge-context-container
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: foreach-patchstrategicmerge-context-pod
|
||||
namespace: foreach-patchstrategicmerge-context-ns
|
||||
spec:
|
||||
containers:
|
||||
- image: busybox
|
||||
name: foreach-patchstrategicmerge-context-container
|
|
@ -0,0 +1,11 @@
|
|||
## Description
|
||||
|
||||
This test ensures that context look up works for mutate foreach.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
The pod image should be mutated to `nginx`.
|
||||
|
||||
## Reference Issue(s)
|
||||
|
||||
N/A
|
Loading…
Add table
Reference in a new issue