1
0
Fork 0
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:
Bricktop 2021-04-26 23:02:52 +02:00 committed by GitHub
parent 434a4cdb14
commit 64f49caa84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -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,
},
}

View file

@ -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