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

Consider replacing the environment overrides properties with variables #147

Open
1 of 4 tasks
blake-mealey opened this issue Jun 14, 2022 · 3 comments
Open
1 of 4 tasks
Labels
enhancement New feature or request next What to work on next
Milestone

Comments

@blake-mealey
Copy link
Owner

blake-mealey commented Jun 14, 2022

What type of feature request is this?

  • Mantle doesn't support a Roblox feature I would like to use
  • Mantle CLI improvement
  • Mantle config improvement
  • Other

Describe your problem
The current environment overrides configuration options are limited and require lots of boilerplate which makes it harder to read.

The targetOverrides provides full flexibility at the cost of making it hard to add simple things and by reducing DRYness. As a result, the targetNamePrefix and targetAccess properties were added as shorthands to targetOverrides modifications. This is not a scalable approach to the config format.

Describe the solution you'd like
Switch to a variable-based approach, where Mantle provides a simple variable expansion to the user's config. Mantle will provide a set of default variables (like environmentLabel) and will allow the user to define their own variables per environment via a variables dictionary property on the environment object.

environments:
 - label: dev
   variables:
     environmentPostfix: ' - Development'
     playability: public
 - label: prod
   variables:
     environmentPostfix: ''
     playability: 
target:
  experience:
    configuration:
      playability: $playability
    places:
      start:
        configuration:
          name: My Game$environmentPostfix

In order for this to work we would need to perform the variable expansion before parsing the config with serde. To do this we could do an initial parse of just the environments property (without any expansion), expand variables on the whole file's contents, then parse with serde.

To make this more useful and powerful we could also allow some simple expressions:

target:
  experience:
    places:
      start:
        configuration:
          name: My Game${ if(ne($environmentLabel, 'prod'), concat(' [', upper($environmentLabel), ']')) }
          name: My Game${ if $environmentLabel != 'prod' then ' [$environmentLabel]' }
@blake-mealey blake-mealey added the enhancement New feature or request label Jun 14, 2022
@blake-mealey
Copy link
Owner Author

blake-mealey commented Dec 21, 2022

Another thing we could consider here is using multiple yaml docs (separated by ---). This way we could parse the first doc to read the environment info and variables, then apply the template to the full config. This would mean expressions could be used to generate keys as well as values.

If we had templates around keys it would wreck formatting in editors. How does Helm solve this? Do we need a Mantle vscode extension?

@blake-mealey blake-mealey added the next What to work on next label Dec 30, 2022
@blake-mealey blake-mealey added this to the v0.12.0 milestone Dec 30, 2022
@blake-mealey
Copy link
Owner Author

Another limitation with targetOverrides is it does not enable overriding configuration outside of target (as seen in #215)

@blake-mealey
Copy link
Owner Author

blake-mealey commented Mar 26, 2024

Proposal for initial implementation:

  1. Split file into 2 separate yaml docs (with ---). Only the environments config should be in the first doc.
  2. Parse the first doc to construct the env context
  3. Expand template expressions in the second doc with the env context

For template expressions, use the ${{ context.variable }} syntax (same as GH actions). For example: ${{ env.environmentSuffix }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request next What to work on next
Projects
None yet
Development

No branches or pull requests

1 participant