chainsaw
chainsaw copied to clipboard
[Feature] Allow to use binding/functions in `use.template` in test step
Describe your question
Hi there,
I'm trying to create reusable (StepTemplate) building blocks and have the following:
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: basic-test
spec:
bindings:
- name: rootPath
value: ../..
- name: templatesPath
value: (join('/', [$rootPath, 'templates']))
steps:
- name: Print path # Works fine
try:
- script:
env:
- name: TEMPLATES_PATH
value: (join('/', [$templatesPath, 'example/custom_bindings.yaml']))
content: |
echo $TEMPLATES_PATH
- name: Test custom bindings
bindings:
- name: filePath
value: (join('/', [$templatesPath, 'example/custom_bindings.yaml']))
use:
# template: ../../templates/example/custom_bindings.yaml
template: $filePath # does NOT work
# template: (join('/', [$templatesPath, 'example/custom_bindings.yaml'])) # does NOT work
Version: 0.2.8
No configuration provided but found default file: .chainsaw.yaml
Loading config (.chainsaw.yaml)...
Loading tests...
Running tests...
=== RUN chainsaw
=== PAUSE chainsaw
=== CONT chainsaw
=== RUN chainsaw/my-test
| 18:46:04 | basic-test | Paths | TRY | RUN |
| 18:46:04 | basic-test | Paths | SCRIPT | RUN |
=== COMMAND
/usr/bin/sh -c echo $TEMPLATES_PATH
| 18:46:04 | basic-test | Paths | SCRIPT | LOG |
=== STDOUT
../../templates/example/custom_bindings.yaml
Version: 0.2.8
No configuration provided but found default file: .chainsaw.yaml
Loading config (.chainsaw.yaml)...
Loading tests...
Error: open tests/basic-test/$filePath: no such file or directory
It seems it's not currently supported or did I miss anything?
Would it be possible to add support for this? There are more use cases for this, the above is just a quick example.
chainsaw version Version
v0.2.8
Additional context
No response