1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

fix: add tests from #6463 (#8250)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-09-04 17:58:43 +02:00 committed by GitHub
parent cef4a9b546
commit 151d0b3298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,19 @@
# Taken from https://github.com/kyverno/kyverno/issues/6463
name: repro-dups-bug
policies:
- policy.yaml
resources:
- resources.yaml
results:
- policy: restrict-something
rule: validate-some-foo
resources:
- nginx-foo
kind: Pod
result: pass
- policy: restrict-something
rule: validate-some-non-foo
resources:
- nginx-too
kind: Pod
result: fail

View file

@ -0,0 +1,42 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-something
spec:
validationFailureAction: audit
background: true
rules:
- name: validate-some-foo
match:
resources:
kinds:
- Pod
namespaces:
- foo
validate:
message: "Unknown image registry."
deny:
conditions:
- key: "{{ images.containers.*.registry }}"
operator: NotIn
value:
- "foo.io"
- name: validate-some-non-foo
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- resources:
namespaces:
- foo
validate:
message: "Unknown image registry."
deny:
conditions:
- key: "{{ images.containers.*.registry }}"
operator: NotIn
value:
- "bar.io"

View file

@ -0,0 +1,19 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx-foo
namespace: foo
spec:
containers:
- name: nginx
image: foo.io/nginx:1.7.9
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-too
namespace: bar
spec:
containers:
- name: nginx
image: foo.io/nginx:1.7.9