Try¶
A try
statement is a sequence of operations executed in the same order they are declared. If an operation fails the entire step is considered failed.
The try
statement is at the heart of a test step, it represents what the step is supposed to be about.
catch and finally statements should be viewed as complementary to the try
statement.
Continue on error
By default a test step stops executing when an operation fails and the following operations are not executed.
This behaviour can be changed using the continueOnError
field, if continueOnError
is set to true
the step will still be considered failed but execution will continue with the next operations.
Operations¶
A try
statement supports all operations:
Example¶
Example
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: example
spec:
steps:
- try:
- command:
# ...
- sleep:
# ...
- script:
# ...
- apply:
# ...
- assert:
# ...
- error:
# ...
- create:
# ...
- patch:
# ...
catch: []
finally: []