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

feat: use more chainsaw test templates (#11281)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2024-10-01 22:46:10 +02:00 committed by GitHub
parent 2bbce68f67
commit 7113aa111a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 422 additions and 424 deletions

View file

@ -0,0 +1,19 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: StepTemplate
metadata:
name: policy-ready
spec:
try:
- assert:
template: true
resource:
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: ($name)
namespace: ($namespace)
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,30 +4,38 @@ metadata:
name: check-old-object
spec:
steps:
- name: step-01
try:
- create:
file: ns.yaml
- assert:
file: ns-ready.yaml
- name: step-02
try:
- create:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: step-03
try:
- update:
file: ns-update.yaml
- name: step-04
try:
- update:
file: ns-update-good.yaml
- name: step-05
try:
- update:
file: ns-update-bad.yaml
expect:
- check:
($error != null): true
- name: step-01
try:
- create:
file: ns.yaml
- assert:
file: ns-ready.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-old-object
- name: step-03
try:
- update:
file: ns-update.yaml
- name: step-04
try:
- update:
file: ns-update-good.yaml
- name: step-05
try:
- update:
file: ns-update-bad.yaml
expect:
- check:
($error != null): true

View file

@ -1,4 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-old-object

View file

@ -4,19 +4,27 @@ metadata:
name: check-old-object
spec:
steps:
- name: step-01
try:
- create:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: step-02
try:
- create:
file: ns.yaml
- assert:
file: ns-ready.yaml
- name: step-03
try:
- update:
file: ns-update.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-old-object
- name: step-02
try:
- create:
file: ns.yaml
- assert:
file: ns-ready.yaml
- name: step-03
try:
- update:
file: ns-update.yaml

View file

@ -1,4 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-old-object

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-event
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-event
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-report
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-report
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: not-rejected
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: not-rejected
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-event
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-event
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-report
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: no-admission-report
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: not-rejected
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: not-rejected
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: validate
- name: step-02
try:
- apply:

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: validate
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: all-scale
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: clusterpolicy
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: double-wildcard
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -5,12 +5,27 @@ metadata:
name: dyn-op-mutate-multiple
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: add-apparmor-annotations
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: add-annotation
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: add-apparmor-annotations
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -5,12 +5,20 @@ metadata:
name: dyn-op-mutate
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: add-apparmor-annotations
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: add-apparmor-annotations
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -5,12 +5,20 @@ metadata:
name: dyn-op-validate
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: only-pod
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: pod-all-subresources
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: pod-exec-subresource
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: std-shell
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: std-shell
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: policy-clusterpolicy-namespaced-clusterscoped-resources
spec:
steps:
- name: step-01
try:
- apply:
file: clusterpolicy.yaml
- assert:
file: clusterpolicy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: clusterpolicy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -7,7 +7,7 @@ spec:
- name: step-01
try:
- apply:
file: policy.yaml
expect:
- check:
($error != null): true
file: policy.yaml

View file

@ -4,12 +4,20 @@ metadata:
name: policy-wildcard-resource
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: policy
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: require-labels
- name: step-02
try:
- assert:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: require-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready