Resource templating¶
Experimental status
This is an experimental feature, and implementation could change slightly in the next versions.
Chainsaw can apply transformations to the resources before they are processed by the operation.
This is useful when a resource needs some runtime configuration.
Templating must be enabled at the configuration, test, step, or operation level for the templating process to kick in. Alternatively, templating can be enabled using the --template
flag when invoking chainsaw from the command line.
Note
Unlike assertion trees, templating can only be specified in leave nodes of the YAML tree.
Example¶
The test below will create, assert, and delete a ConfigMap
with a dynamic name
configured at runtime using the $namespace
binding.
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: values
spec:
steps:
- try:
- apply:
resource:
apiVersion: v1
kind: ConfigMap
metadata:
name: ($namespace)
- assert:
resource:
apiVersion: v1
kind: ConfigMap
metadata:
name: ($namespace)
- delete:
ref:
apiVersion: v1
kind: ConfigMap
name: ($namespace)