-
Notifications
You must be signed in to change notification settings - Fork 267
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
[FEATURE]: elseif branches in templating. #5738
Comments
Updated to include another attempt at a workaround that failed. |
@salotz absolutely, this is indeed an annoying problem. Thank you for the report! At the moment we are parsing the document as YAML first, and then apply structural (like We do have long-term plans internally how we can address this issue to make the configuration more expressive. In the mean time, I have two other workarounds for you:
These workarounds are in no way optimal or equivalent to elseif branching, but due to the technical limitations of the current template system it's hard to address this problem. There might be lower hanging fruits to improving the situation, and we are definitely open for suggestions. |
Here is a proposal of an alternative syntax that is easier to implement with the current limitations of the YAML template system:
|
Feature Request
Background / Motivation
Currently you are limited to in all of the branching templating to only two branches.
I.e. ternary operator and if-else.
For instance if I have the following:
And I want to now have two different branches in addition to the one for 'local' there isn't really a way to do that.
So I end up needing to do things like templating the item names e.g.:
Which you can see is just a band aid.
Whats worse is that I can't even use multiple if-else inside the same map/list due to how it expands those. E.g.
Gives an error like:
What should the user be able to do?
If
environment.name
doesn't match this would be a templating error. If there is the trailing else it would be fine.Why do they want to do this? What problem does it solve?
See above.
Suggested Implementation(s)
The obvious near term fix is to just add support for the elseif part.
In general I think that support for a pre-existing and powerful templating engine (like jsonnet) would be a more holistic approach to addressing non-essential garden functionality like this.
How important is this feature for you/your team?
Its not critical now, but as our stacks grow they increasingly grow ugly hacks and workarounds to this issue.
🌵 Not having this feature makes using Garden painful
The text was updated successfully, but these errors were encountered: