Helm Functions
Helm functions are provided by the jhelm-gotemplate-helm module.
They are auto-discovered via ServiceLoader when the module is on the classpath (priority 200, overrides Sprig on name collision).
1. Template Functions
| Function | Description |
|---|---|
|
Execute named template and return output as string. Returns empty string on error. |
|
Execute named template and return output. Throws on error. |
|
Evaluate string as template inline. Returns empty string on error. |
|
Evaluate string as template inline. Throws on error. |
|
Validate that a value is present and non-empty. Throws with the provided message if validation fails. |
metadata:
labels:
{{- include "mychart.labels" . | nindent 4 }}
image: {{ required "image.repository is required" .Values.image.repository }}
2. Conversion Functions
2.1. YAML
| Function | Description |
|---|---|
|
Converts object to YAML string. Null fields are omitted, numeric-looking strings are quoted. Returns empty string on error. |
|
Same as |
|
Parses YAML string into a Map. Returns empty map on error. |
|
Same as |
|
Parses YAML string into a List. Returns empty list on error. |
|
Same as |
2.2. JSON
| Function | Description |
|---|---|
|
Converts object to JSON string. Returns |
|
Same as |
|
Converts object to pretty-printed JSON. Returns |
|
Same as |
|
Converts object to JSON without HTML escaping. Returns |
|
Same as |
|
Parses JSON string into a Map. Returns empty map for null, blank, or |
|
Same as |
|
Parses JSON string into a List. Returns empty list for null, blank, or |
|
Same as |
3. Kubernetes Functions
| Function | Description |
|---|---|
|
Query the Kubernetes API for resources, returning the whole object (metadata, |
|
Returns Kubernetes cluster version info as a Map with keys |
In the CLI and any jhelm-kube-backed application these functions query the live
cluster (as Helm does during install/upgrade) — the Spring auto-configuration wires a
cluster-backed KubernetesProvider into the engine automatically. Without a wired provider
(for example the standalone gotmpl4j engine, or when the API server is unreachable),
lookup returns an empty map and kubeVersion returns the stub — so offline template
rendering still works. A provider can also be supplied manually via GoTemplate.Builder.
|