Scripts¶
In addition to collecting pod logs and events, Chainsaw also supports arbitrary scripts as collectors.
Shell
Scripts require a shell to run, Chainsaw executes scripts with sh -c ...
.
If no shell is available, Scripts
can't be used.
Configuration¶
The full structure of the Script
resource is documented here.
A Script
must have a content
defined.
Simple command
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: example
spec:
steps:
- try:
- apply:
file: my-pod.yaml
- assert:
file: my-pod-assert.yaml
catch:
- script:
content: |
echo "an error has occured"
Timeout¶
An optional timeout
can be configured.
Note
Note that the timeout
lives at the operation level, not at the script
level.
Timeout example
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: example
spec:
steps:
- try:
- apply:
file: my-pod.yaml
- assert:
file: my-pod-assert.yaml
catch:
- script:
content: |
echo "an error has occured"
timeout: 30s