Helm Generator
A resource generator for Helm charts
Sometimes it is desired to write a component operator (using component-operator-runtime) for some cluster component, which already has a productive Helm chart. Then it can make sense to use the HelmGenerator implementation of the Generator interface included in this module:
package helm
func NewHelmGenerator(
fsys fs.FS,
chartPath string,
clnt client.Client,
) (*HelmGenerator, error)
Here:
fsysmust be an implementation offs.FS, such asembed.FS; or it can be passed as nil; then, all file operations will be executed on the current OS filesystem.chartPathis the directory containing the used Helm chart; iffsyswas provided, this has to be a relative path; otherwise, it will be interpreted with respect to the OS filesystem (as an absolute path, or relative to the current working directory of the controller).clntshould be a client for the local cluster (i.e. the cluster where the component object exists).
It should be noted that HelmGenerator does not use the Helm SDK; instead it tries to emulate the Helm behavior as good as possible.
A few differences and restrictions arise from this:
- Not all Helm template functions are supported. To be exact,
toTomlis not supported; all other functions should be supported, but may behave more strictly in error situtations. - Not all builtin variables are supported; the following restrictions apply:
- for the
.Releasebuiltin, only.Release.Namespace,.Release.Name,.Release.Service,.Release.IsInstall,.Release.IsUpgradeare supported; note that - since this framework does not really distinguish between installations and upgrades -Release.IsInstallis always set totrue, andRelease.IsUpgradeis always set tofalse - for the
.Chartbuiltin, only.Chart.Name,.Chart.Version,.Chart.Type,.Chart.AppVersion,.Chart.Dependenciesare supported - for the
.Capabilitiesbuiltin, only.Capabilities.KubeVersionand.Capabilities.APIVersionsare supported - the
.Templatebuiltin is fully supported - the
.Filesbuiltin is supported but does not return any of the paths reserved by Helm (such asChart.yaml,templates/and so on)
- for the
- Regarding hooks,
pre-deleteandpost-deletehooks are not allowed; test and rollback hooks are ignored, andpre-install,post-install,pre-upgrade,post-upgradehooks might be handled in a sligthly different way; hook weights will be handled in a compatible way; hook deletion policyhook-failedis not allowed, butbefore-hook-creationandhook-succeededshould work as expected. - The
.helmignorefile is currently not evaluated; in particular, files can be accessed through.Filesaltough they are listed in.helmignore.