-
Notifications
You must be signed in to change notification settings - Fork 172
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
Bosh Templating Language RFC #1004
base: main
Are you sure you want to change the base?
Conversation
c04da21
to
8459a3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add some examples of what the new grammar would look like for at least the basic usecases (if_p
, p('something').each do |prop|
, multi line certs (with respecting indentation, some to_json/yaml, etc)?
Data transformation should be happening within the release runtimes or pre-start scripts. Validation can also happen | ||
there, although it's possible we want to expand the Bosh Release `spec` files to provide some level of validation so | ||
errors can be caught early in the deploy process (that work is NOT part of this RFC). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARP does A LOT of validation in the template. I always thought this was best practice because then the user gets an error far earlier in the deploy process.
Here are some examples of the validations we have:
- provided IPs are valid IPs
- integer ranges (must be larger than X or smaller than X)
- do domains end with a "."? If not, add one.
- if you set X, Y, Z property, then fail if a cert is not provided. Else it is fine.
- a provided string must be either "a" or "b"
- string length must be more than X
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added more specific examples with links in this comment: #1004 (comment)
ARP releases do a lot of "check to see if this property is provided, if not then use the property from a bosh link". Is this type of logic someone that would be provided? But really, I second what @rkoster said above asking for examples of what you want to include in your templating language, that way I can be more specific in my worries 😅 |
I come bearing examples of template logic!
After going through all these files I see that nearly every one of ours has this helper method defined. It would be great if you owned these types of helper functions :)
|
What is the percentage of structured vs. unstructured output being rendered? Background is, that https://cue-lang.org would be a great option to replace the release specs and include validation (like X : Int >3 but < 7) and for structured rendering output it could also directly be used for that. If we have a huge amount of unstructured formats, it might be a challenge. I could still see removing the need to validate from the templating language by using CUE. Edit: I guess this would be relevant, when it comes to unstructured data and templating / interpolation: https://cuelang.org/docs/tour/expressions/interpolation/ |
If we want to push logic out of the templates why not drop the central template rendering altogether and allow release authors to consume the YAML directly? The provided YAML would be placed in the config directory of the job and the release decides how to proceed with it. This would also work around the core issue here which I think is dependency management: the release authors are implementing against a templating system which is controlled by the user of the release (e.g. the operator) and not the release author. By explicitly making the template rendering a part of the release itself we solve that issue. Bumping the template renderer becomes the responsibility of the release author which can properly test and resolve any issues with version bumps. And the operator no longer risks breaking a bunch of releases just because the ruby version or some required dependency is bumped in their environment. If we still want BOSH to be able to distinguish between the templating and pre-start phase we could add an additional lifecycle step. If the release author provides a script for that step the ERB rendering is automatically disabled. And for release which don't want to switch a Ruby script which mimics the behaviour of the old template rendering could be provided / injected to speed up the transition. Edit: as many jobs are running code written and maintained by the community this would allow to skip the intermediate config representation that often exists without any template rendering at all by incorporating the logic into the job itself. I guess this is technically already possible today, but the ERB templates might somewhat steer people to having an additional step? Edit: this does not address the concern about failing before the deploy itself starts happening. |
Proposal for adding a new templating language for bosh releases
Preview