[WiP] Support template expansion of YAML files #387
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why do we need it
I encountered a few cases where I needed
kuttl
to match a field to a value that depends on the execution environment. Examples:status
field in order to verify that an upgrade succeeded. The version string is produced based on git commit SHA dynamically by the build tooling.I ended up creating a
TestAssert
containing a script which:envsubst
kuttl assert
on the resulting fileAs you can imagine, the result is not pretty or straightforward to understand at first sight.
Other issues that I found which might (or might not) be helped by this change: #70 #160 #350 #288 #262 #224 #222 #203
What this PR does
During a recent team hackathon I took a stab at finding out how difficult it would be to do the template expansion directly within
kuttl
. Turns out it was not too difficult, and the result works. But please keep in mind this is a hack, not meant to be merged as is. But might be a useful inspiration on the necessary work.For backwards compatibility I introduced a notion of
*.gotmpl.yaml
files, and only these are expanded. The dictionary of expansion keys (TemplatingContext
) also needs some more thought. For now it consists of the namespace and environment.