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

Bosh Templating Language RFC #1004

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions toc/rfc/rfc-draft-add-new-bosh-release-templating-language.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Meta
[meta]: #meta
- Name: Bosh Templating Language
- Start Date: 2024-10-21
- Author(s): jpalermo
- Status: Draft
- RFC Pull Request: [community#1004](https://github.com/cloudfoundry/community/pull/1004)


## Summary

Introduce new custom templating language that can be used by bosh releases. Ideally gather feedback from release
authors as part of the RFC process to define the MVP of the language.

## Problem

Currently all bosh release templates are rendered using ERB using the Bosh Director's Ruby process, or whatever
Ruby process is available when a `bosh create-env` is being run.

We've had multiple release breakages over the years as we upgrade the Bosh Director Ruby version and the Ruby
language changes in a way that release templates were not expecting.

A secondary problem is that template rendering can be slow when rendering templates for large CF deployments.

## Proposal

Write a library/cli that defines a strict grammar suitable for basic template rendering within Bosh releases.

A proof of concept can be found [here](https://github.com/jpalermo/bosh-template-renderer).

We would NOT be removing ERB rendering as an option anytime in the near future. We would update many of the Bosh
Releases in the Foundational Infrastructure Working Group to use the new templates and then target releases
that are on Diego Cells as large CF deployments render those same templates a large number of times.

Having a grammar under our control means we can ensure it does not change or break through golang and dependency
upgrades.

The Bosh Director is written in Ruby, so it will be able to shell out to the CLI to render templates. While
the Bosh CLI is written in golang so it will be able to import the library and use it directly.

The grammar would be kept relatively small. We will not be providing a direct replacement for ERB. Many validations
and data transformations are happening within ERB templates right now that should be happening at different layers
of the deployment process.

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).
Comment on lines +45 to +47
Copy link
Member

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

Copy link
Member

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)