mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
test-cases for wildcard match label selector (#3165)
This commit is contained in:
parent
11311a15df
commit
b3f702ba8d
3 changed files with 138 additions and 0 deletions
|
@ -0,0 +1,31 @@
|
|||
name: wildcard-support-in-matchlabels
|
||||
policies:
|
||||
- policy.yaml
|
||||
resources:
|
||||
- resources.yaml
|
||||
results:
|
||||
- policy: wildcard-support-in-matchlabels
|
||||
rule: wildcard-label
|
||||
resource: my-service-1
|
||||
kind: Pod
|
||||
result: pass
|
||||
- policy: wildcard-support-in-matchlabels
|
||||
rule: label-end-with-test
|
||||
resource: my-service-2
|
||||
kind: Pod
|
||||
result: pass
|
||||
- policy: wildcard-support-in-matchlabels
|
||||
rule: label-end-with-test
|
||||
resource: my-service-3
|
||||
kind: Pod
|
||||
result: skip
|
||||
- policy: wildcard-support-in-matchlabels
|
||||
rule: label-start-with-test
|
||||
resource: my-service-4
|
||||
kind: Pod
|
||||
result: pass
|
||||
- policy: wildcard-support-in-matchlabels
|
||||
rule: label-start-with-test
|
||||
resource: my-service-5
|
||||
kind: Pod
|
||||
result: skip
|
50
test/cli/test/wildcard_match_label_selector/policy.yaml
Normal file
50
test/cli/test/wildcard_match_label_selector/policy.yaml
Normal file
|
@ -0,0 +1,50 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: wildcard-support-in-matchlabels
|
||||
spec:
|
||||
validationFailureAction: enforce
|
||||
background: false
|
||||
rules:
|
||||
- name: wildcard-label
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- Pod
|
||||
selector:
|
||||
matchLabels:
|
||||
protected: "*"
|
||||
validate:
|
||||
message: "Using a mutable image tag e.g. 'latest' is not allowed."
|
||||
pattern:
|
||||
spec:
|
||||
containers:
|
||||
- image: "!*:latest"
|
||||
- name: label-end-with-test
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- pod
|
||||
selector:
|
||||
matchLabels:
|
||||
protected: "*-test"
|
||||
validate:
|
||||
message: "Using a mutable image tag e.g. 'latest' is not allowed."
|
||||
pattern:
|
||||
spec:
|
||||
containers:
|
||||
- image: "!*:latest"
|
||||
- name: label-start-with-test
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- pod
|
||||
selector:
|
||||
matchLabels:
|
||||
protected: "test-*"
|
||||
validate:
|
||||
message: "Using a mutable image tag e.g. 'latest' is not allowed."
|
||||
pattern:
|
||||
spec:
|
||||
containers:
|
||||
- image: "!*:latest"
|
57
test/cli/test/wildcard_match_label_selector/resources.yaml
Normal file
57
test/cli/test/wildcard_match_label_selector/resources.yaml
Normal file
|
@ -0,0 +1,57 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: my-service-1
|
||||
labels:
|
||||
protected: "true"
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: my-service-2
|
||||
labels:
|
||||
protected: "label-test"
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: my-service-3
|
||||
labels:
|
||||
protected: "label-fail"
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: my-service-4
|
||||
labels:
|
||||
protected: "test-label"
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: my-service-5
|
||||
labels:
|
||||
protected: "fail-label"
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
Loading…
Add table
Reference in a new issue