mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 02:18:15 +00:00
test: add kuttl tests for jmespath special chars (#5310)
* Adds tests for fixes in #4767 Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com> Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com> Co-authored-by: shuting <shuting@nirmata.com>
This commit is contained in:
parent
001db94d87
commit
97a2b9a9a3
7 changed files with 80 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- policy.yaml
|
||||
assert:
|
||||
- policy-assert.yaml
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- resources.yaml
|
||||
assert:
|
||||
- resources-assert.yaml
|
|
@ -0,0 +1,12 @@
|
|||
## Description
|
||||
|
||||
This test checks that document references with special characters in their names are supported.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
JMESPath references generated when documents are traversed are escaped properly according to the JMESPath standard.
|
||||
|
||||
## Reference Issue(s)
|
||||
|
||||
3578
|
||||
3616
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: jmespath-with-special-chars-demo
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,28 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: jmespath-with-special-chars-demo
|
||||
spec:
|
||||
rules:
|
||||
- name: format-deploy-zone
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
mutate:
|
||||
patchStrategicMerge:
|
||||
metadata:
|
||||
labels:
|
||||
deploy-zone: "{{ to_upper('{{@}}') }}"
|
||||
- name: retention-adjust
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
mutate:
|
||||
patchStrategicMerge:
|
||||
metadata:
|
||||
labels:
|
||||
corp.com/retention: "{{ regex_replace_all('([0-9])([0-9])', '{{ @ }}', '${1}0') }}"
|
|
@ -0,0 +1,7 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: busybox
|
||||
labels:
|
||||
deploy-zone: FRANKFURT
|
||||
corp.com/retention: days_30
|
|
@ -0,0 +1,12 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: busybox
|
||||
labels:
|
||||
deploy-zone: frankfurt
|
||||
corp.com/retention: days_37
|
||||
spec:
|
||||
containers:
|
||||
- name: busybox
|
||||
image: busybox:stable
|
||||
command: ["sleep", "600"]
|
Loading…
Add table
Reference in a new issue