Templating
You can use templating in any file, with any extension. Helmize renders each file with sprig any validates, if it generates YAML output. You have access to the file context within each file. Lets template! :)
Helmize comes with our helm library as dependency. The library provides a lot of functions which simplify the maniplution of dicts, slices, etc. You should definitly make use of it’s functionalities. See the full documentation of the library chart here:
The mergering of files is not implement with the normal merge
function from sprig. We have implemented our own merge function which allows the recusrive merging of list elements, which is per default not possible. Meaning you can merge the list objects from base data and new data and merge list elements of type dict based on an attribute. Which are crucial functionalities to reduce code and make life easier. See the documentation:
This function might have some bugs, but we are doing our best to unit test it and make sure it works as expected.
Contexts are data structures. In Sprig a template receives a context. Based on which context is given, you have acces to certain data.
With this example https://github.com/buttahtoast/helmize/tree/main/examples/data you can see the file contexts. helm template . --set showContext=true
The context available in each file:
- See Condition Context
- See Global Context
The train is a construct which mainly holds the general configuration and consists of wagons.
A wagon is the construct which abstracts a group of files into one file. The files are grouped into wagons based on their identifier. The Train is a list of wagon contexts.
The Global Context is the default helm context for a chart enriched with some extra fields for helmize.
The Condition is always available.
- All (previously) evaluated conditions can be accessed under
$.conditions
. The$.conditions.[*].value
holds the resolved value from the$.conditions.[*].key
property. - When you template wagons, you can access the conditions Data field which selected this file via
$.data
(Reference to$.Conditions.[*].data
field) - When you template wagons, you can access the conditions Value field which selected this file via
$.value
(Reference to$.Conditions.[*].value
field).