mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 16:06:56 +00:00
tests: add chainsaw test for image data loading (#12077)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
ac45755fc5
commit
c78ab6654c
3 changed files with 59 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
|
||||||
|
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||||
|
kind: Test
|
||||||
|
metadata:
|
||||||
|
name: image-data
|
||||||
|
spec:
|
||||||
|
steps:
|
||||||
|
- name: create policy
|
||||||
|
try:
|
||||||
|
- create:
|
||||||
|
file: policy.yaml
|
||||||
|
- sleep:
|
||||||
|
duration: 10s
|
||||||
|
- name: create deployment
|
||||||
|
try:
|
||||||
|
- create:
|
||||||
|
file: deployment.yaml
|
|
@ -0,0 +1,19 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: deployment
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: nginx
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx:latest
|
|
@ -0,0 +1,23 @@
|
||||||
|
apiVersion: kyverno.io/v2alpha1
|
||||||
|
kind: ValidatingPolicy
|
||||||
|
metadata:
|
||||||
|
name: check-deployment-labels
|
||||||
|
spec:
|
||||||
|
matchConstraints:
|
||||||
|
resourceRules:
|
||||||
|
- apiGroups: [apps]
|
||||||
|
apiVersions: [v1]
|
||||||
|
operations: [CREATE, UPDATE]
|
||||||
|
resources: [deployments]
|
||||||
|
variables:
|
||||||
|
- name: image
|
||||||
|
expression: >-
|
||||||
|
context.GetImageData("ghcr.io/kyverno/kyverno:latest")
|
||||||
|
- name: accept
|
||||||
|
expression: >-
|
||||||
|
variables.image != null
|
||||||
|
validations:
|
||||||
|
- expression: >-
|
||||||
|
variables.accept
|
||||||
|
message: >-
|
||||||
|
Deployment must be accepted
|
Loading…
Add table
Reference in a new issue