Add templating to porter config file #1879
Merged
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.
What does this change
Support templating in the Porter config file, e.g.
~/.porter/config.json|toml|yaml.
The template syntax uses a yaml-friendly delimiiter, ${}. For example,
${env.NAME} or ${secret.NAME}. If you are using toml or json for your
config file format, then you may need to use quotes around template
values to ensure that the config file has valid syntax when it is
loaded.
We load the config file first with only environment variables
substituted, then we initialize the secrets plugin, and finally do a
second pass of the config file to replace any secrets. So that first
pass needs to be a valid file based on the current format.
For example, in a porter.toml file, secrets should be quoted:
Only environment variables and secrets can be substituted. The secrets
are resolved from the default secret storage.
I am implementing this with the liquid template engine (from shopify
that was ported to Go). I don't want us to commit to supporting liquid
templates at this time, it's just an implementation detail that liquid
is used at the moment and it could change later.
Preview of the config documentation at https://deploy-preview-1879--porter.netlify.app/configuration/
What issue does it fix
Closes #1763
Notes for the reviewer
Eventually porter.yaml will transition to this new template delimiter before v1.
Checklist
Reviewer Checklist