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

implement config variables prototype #216

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

blake-mealey
Copy link
Owner

@blake-mealey blake-mealey commented Apr 28, 2024

Implements a prototype of #147:

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

Copy link

vercel bot commented Apr 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mantle-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 28, 2024 10:36pm

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