Skip to content

test(template): pin that a Helm chart commits verbatim (#7) - #20

Merged
braghettos merged 1 commit into
mainfrom
test/7-helm-chart-passthrough
Sep 18, 2026
Merged

braghettos merged 1 commit into
mainfrom
test/7-helm-chart-passthrough

Conversation

@braghettos

Copy link
Copy Markdown

Closes #7 — as already fixed, with the coverage that was missing.

#7 is fixed, and more cleanly than it proposed

The issue's primary fix was "skip the template render when there are no placeholders." What was actually done is stronger: the default delimiters moved {{ }} → {% %}, so Helm's syntax is no longer the delimiter and passes through untouched — placeholders or not.

The alternatives were tested against real YAML before choosing, per the comment in template.go:

<< >>   breaks on the YAML merge key `<<: *defaults`   (parse error: expected :=)
[[ ]]   breaks on flow sequences `[[1,2],[3,4]]`       (parse error: unexpected ",")
{% %}   safe against both, and not Helm syntax

What was missing

Coverage at the render level. validate_test.go asserts Helm syntax isn't reported under the default delimiters — but nothing asserted it survives a render byte-for-byte, which is the actual claim #7 is about, and exactly what a future delimiter change would silently break.

This test

Renders the content that failed on krateo-057 (publish-sock-shop-003 / microservices.yaml):

resources:
  {{- toYaml .Values.resources | nindent 4 }}
{{- include "chart.labels" . }}
{{/* a helpers.tpl header */}}
value: {{ .Values.name }}

…and asserts the output is identical to the input. That covers all four things #7 listed: the undefined Helm funcs (toYaml, include), the {{/* */}} header helm create writes into every _helpers.tpl and which used to be deleted outright, and .Values references that used to render to a literal <no value>.

Verified failing intent: under {{ }} delimiters this content errors with exactly the reported function "toYaml" not defined.

🤖 Generated with Claude Code

https://claude.ai/code/session_017tUn92TdGikKGEN5opGD7q

#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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tUn92TdGikKGEN5opGD7q
@braghettos
braghettos merged commit e579154 into main Sep 18, 2026
3 checks passed
@braghettos
braghettos deleted the test/7-helm-chart-passthrough branch September 18, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LocalResource templates fromString unconditionally (Go text/template + sprig) → committing a file that itself contains {{ }} (e.g. a Helm chart) fails

1 participant