Config files are split into separate YAML documents within the same file, separated by ---:
The first document is the "header" which contains the environments and state properties
The second document is the "body" which contains everything else
When the config file is loaded, the header document is parsed as normal and the environment determined as before. Then, the body document is rendered as a template using various contexts before being parsed as before.
Templates use the tinytemplate crate for rendering. Syntax is very basic: {context.variable}.
Contexts:
env:
Contains the label variable which is set to the selected environment's label
vars:
Contains variables configured under environments.variables for the selected environment
environments.*.target_name_prefix is removed
environments.*.target_access is removed
environments.*.target_overrides is removed
environments.*.variables is added and will be used to populate the vars context
I do not intend to use tinytemplate for production since it is too basic, but it was useful for getting a prototype working. For a proper implementation I would like the template rendering to:
Use ${{}} syntax so that the templates don't break YAML syntax
Support rendering object and array values (currently it only supports primitive values)
Support simple function expressions (e.g. coalesce, concat)
Support simple arithmetic expressions (e.g. +, -)
Support simple condition expressions (e.g. if <cond> {} else {})
Support literal expressions (e.g. 'literal string')
See light/mantle.yml in this prototype for example configuration file.
Implements a prototype of #147:
---
:environments
andstate
properties{context.variable}
.env
:label
variable which is set to the selected environment's labelvars
:environments.variables
for the selected environmentenvironments.*.target_name_prefix
is removedenvironments.*.target_access
is removedenvironments.*.target_overrides
is removedenvironments.*.variables
is added and will be used to populate thevars
contextI do not intend to use
tinytemplate
for production since it is too basic, but it was useful for getting a prototype working. For a proper implementation I would like the template rendering to:${{}}
syntax so that the templates don't break YAML syntaxcoalesce
,concat
)+
,-
)if <cond> {} else {}
)'literal string'
)See
light/mantle.yml
in this prototype for example configuration file.