Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WiP] Support template expansion of YAML files #387

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

porridge
Copy link
Member

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:

  • product version string in a 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.
  • cluster-scoped resources whose name includes the name of the test namespace

I ended up creating a TestAssert containing a script which:

  1. does poor man's template expansion using envsubst
  2. invokes a (nested) kuttl assert on the resulting file
  3. deletes the temporary assert file

As 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant