helmtk is a toolkit for Helm chart maintainers.
Prefer video? Here's a quick demo.
Helm charts struggle with indentation. Significant whitespace in YAML combined with a text-based template language leads to charts which are buggy and difficult to maintain.
{{- and | nindent| quote| toYaml.yes/no as a boolean (e.g. the norway bug){{- define "namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}
metadata:
labels:
{{- with .Chart.AppVersion }}
app.kubernetes.io/version: {{ . | quote }}
{{- end }}
{{- include "foo.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
helmtk provides a structured template language, allowing templating without significant whitespace.
{
"ports": [
{
"containerPort": 8000
"name": "http"
}
if Values.debug do
{ "containerPort": 5005, "name": "debug" }
end
for name, port in Values.tcpPorts do
{ "containerPort": port, "name": name }
end
]
}
helmtk compile compiles the helmtk code into Helm chart templates.
Helm chart maintainers get the benefits of helmtk without disrupting existing users of the Helm charts.
{
"ports": [
{
"containerPort": 8000,
"name": "http",
},
{{- if .Values.debug -}}
{
"containerPort": 5005,
"name": "debug",
},
{{- end -}}
{{- range $name, $port := .Values.tcpPorts -}}
{
"containerPort": {{ $port | toJson }},
"name": {{ $name | toJson }},
},
{{- end }}
]
}
helmtk test makes writing and running tests easy.
test("test debug port", t => {
t.Values.debug = true
let res = t.render()[0]
t.eq(res.ports[1].name, "debug")
})
$> helmtk test
example.js
✓ test debug port
helmtk decompile automatically imports existing charts into helmtk, including a comprehensive test
suite.
helmtk decompile
> found: templates/_helpers.tpl
> found: templates/deployment.yaml
> found: templates/hpa.yaml
> found: templates/httproute.yaml
> found: templates/ingress.yaml
> found: templates/service.yaml
> found: templates/serviceaccount.yaml
> found: templates/tests/test-connection.yaml
✓ a helmtk file already exists for templates/_helpers.tpl
> validating helmtk/templates/_helpers.helmtk
✓ file parses helmtk/templates/_helpers.helmtk
✓ a test file already exists for helmtk/tests/_helpers.js
> verifying test suite with the helm renderer: helmtk/tests/_helpers.js
✓ test suite passed with the helm renderer: helmtk/tests/_helpers.js
...
The helmtk VS Code extension provides:
