From 636e2b573052c6a50b8e24608154c9455be5a71b Mon Sep 17 00:00:00 2001 From: Diego Braga Date: Fri, 18 Sep 2026 12:08:04 +0200 Subject: [PATCH] test(template): pin that a Helm chart commits verbatim (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #7 reported that committing a Helm chart failed, because fromString was rendered through Go text/template with sprig and Helm's own funcs are not sprig's: create failed: unable to copy files: template: template:61: function "toYaml" not defined That is already fixed, and more cleanly than the issue's own proposal (which was to skip the render when no placeholders are set): the default delimiters moved from {{ }} to {% %}, so Helm's syntax is no longer the delimiter and passes through untouched. The alternatives were tested against real YAML first — << >> breaks on the merge key <<: *defaults, and [[ ]] breaks on flow sequences. What was missing is coverage at the RENDER level. validate_test.go asserts Helm syntax is not *reported* under the default delimiters, but nothing asserted it survives a render byte-for-byte — which is the actual claim #7 is about, and the one a future delimiter change would break. This renders the reported content (toYaml + nindent, include, a {{/* */}} helpers.tpl header, and a .Values reference) and asserts the output is identical to the input. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_017tUn92TdGikKGEN5opGD7q --- .../tools/template/helm_passthrough_test.go | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 internal/tools/template/helm_passthrough_test.go diff --git a/internal/tools/template/helm_passthrough_test.go b/internal/tools/template/helm_passthrough_test.go new file mode 100644 index 0000000..ec28935 --- /dev/null +++ b/internal/tools/template/helm_passthrough_test.go @@ -0,0 +1,21 @@ +package template + +import "testing" + +func TestHelmChartPassesThroughVerbatim(t *testing.T) { + // The file that failed on krateo-057: publish-sock-shop-003 / microservices.yaml + // "create failed: unable to copy files: template: template:61: function \"toYaml\" not defined" + body := `resources: + {{- toYaml .Values.resources | nindent 4 }} +{{- include "chart.labels" . }} +{{/* a helpers.tpl header */}} +value: {{ .Values.name }} +` + got, err := Template(body).Render(map[string]any{}) + if err != nil { + t.Fatalf("a Helm chart must commit verbatim, got render error: %v", err) + } + if string(got) != body { + t.Errorf("content was altered.\n--- want ---\n%s\n--- got ---\n%s", body, got) + } +}