What happened?
When running helm template with a post-renderer on a chart containing the following template:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
value: |
my value
with multiple lines<EOF>
(<EOF> here is supposed to indicate that the template file ends there, so there is no trailing newline) Helm 4 will output the following:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
value: |-
my value
with multiple lines
Note the |- on the value, indicating that trailing whitespace is trimmed.
This behaviour does not occur when not using a post-renderer.
I think technically the behaviour of the version with the post-renderer is more accurate, as the resulting manifest reflects what a compliant YAML parser would make of the template without any involvement of Helm. However, this should be consistent rather than dependent on the use of a post-renderer. Furthermore, this does not match Helm 3.
What did you expect to happen?
In Helm 3, the same template with a post renderer would output the following:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
value: |
my value
with multiple lines
Note the trailing newline which gets preserved by the | multi-line string literal.
How can we reproduce it (as minimally and precisely as possible)?
Use a template like the above #without a trailing newline# where the end of the file coincides with the end of a multi-line string literal. Then template that chart with some post-renderer.
Helm version
Details
$ helm version
version.BuildInfo{Version:"v4.1.3", GitCommit:"c94d381b03be117e7e57908edbf642104e00eb8f", GitTreeState:"clean", GoVersion:"go1.25.8", KubeClientVersion:"v1.35"}
Note that this occurs on all 4.x releases of Helm.
Kubernetes version
Details
$ kubectl version
Client Version: v1.34.3
Kustomize Version: v5.7.1
What happened?
When running
helm templatewith a post-renderer on a chart containing the following template:(
<EOF>here is supposed to indicate that the template file ends there, so there is no trailing newline) Helm 4 will output the following:Note the
|-on the value, indicating that trailing whitespace is trimmed.This behaviour does not occur when not using a post-renderer.
I think technically the behaviour of the version with the post-renderer is more accurate, as the resulting manifest reflects what a compliant YAML parser would make of the template without any involvement of Helm. However, this should be consistent rather than dependent on the use of a post-renderer. Furthermore, this does not match Helm 3.
What did you expect to happen?
In Helm 3, the same template with a post renderer would output the following:
Note the trailing newline which gets preserved by the
|multi-line string literal.How can we reproduce it (as minimally and precisely as possible)?
Use a template like the above #without a trailing newline# where the end of the file coincides with the end of a multi-line string literal. Then template that chart with some post-renderer.
Helm version
Details
Kubernetes version
Details