mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 10:55:05 +00:00
Add e2e test with nested jmesPath in context (#1786)
Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>
This commit is contained in:
parent
434a4cdb14
commit
64f49caa84
2 changed files with 30 additions and 0 deletions
|
@ -15,4 +15,8 @@ var MutateTests = []struct {
|
|||
TestName: "test-mutate-with-logic-in-context",
|
||||
Data: configMapMutationWithContextLogicYaml,
|
||||
},
|
||||
{
|
||||
TestName: "test-mutate-with-context-label-selection",
|
||||
Data: configMapMutationWithContextLabelSelectionYaml,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -57,6 +57,30 @@ spec:
|
|||
+(kyverno.key/copy-me): "{{ labelValue }}"
|
||||
`)
|
||||
|
||||
var configMapMutationWithContextLabelSelectionYaml = []byte(`
|
||||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: "mutate-policy"
|
||||
spec:
|
||||
rules:
|
||||
- name: "gen-role"
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- ConfigMap
|
||||
context:
|
||||
- name: labelValue
|
||||
apiCall:
|
||||
urlPath: "/api/v1/namespaces/{{ request.object.metadata.namespace }}/configmaps"
|
||||
jmesPath: "items[?metadata.name == '{{ request.object.metadata.labels.\"kyverno.key/copy-from\" }}'].metadata.labels.\"kyverno.key/copy-me\" | [0]"
|
||||
mutate:
|
||||
patchStrategicMerge:
|
||||
metadata:
|
||||
labels:
|
||||
+(kyverno.key/copy-me): "{{ labelValue }}"
|
||||
`)
|
||||
|
||||
// Source ConfigMap from which data is taken to copy
|
||||
var sourceConfigMapYaml = []byte(`
|
||||
apiVersion: v1
|
||||
|
@ -78,6 +102,8 @@ kind: ConfigMap
|
|||
metadata:
|
||||
name: target
|
||||
namespace: test-mutate
|
||||
labels:
|
||||
kyverno.key/copy-from: source
|
||||
data:
|
||||
data.yaml: |
|
||||
some: data
|
||||
|
|
Loading…
Add table
Reference in a new issue