From 4e81adb8d73fc4df7b7af383708cc43cadfceb85 Mon Sep 17 00:00:00 2001 From: waterWang <672684719@qq.com> Date: Sat, 22 Aug 2026 13:55:51 +0800 Subject: [PATCH 1/3] fix(template): trim trailing newline from rendered manifests to match v4.1.x stdout output --- pkg/action/action.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index bcc91816c..3c66b9cac 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -355,7 +355,7 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, if strings.TrimSpace(content) == "" { continue } - fmt.Fprintf(b, "---\n# Source: %s\n%s\n", name, content) + fmt.Fprintf(b, "---\n# Source: %s\n%s\n", name, strings.TrimRight(content, "\n")) } return hs, b, "", err } @@ -484,7 +484,7 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, if includeCrds { for _, crd := range ch.CRDObjects() { if outputDir == "" { - fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Filename, string(crd.File.Data)) + fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Filename, strings.TrimRight(string(crd.File.Data), "\n")) } else { err = writeToFile(outputDir, crd.Filename, string(crd.File.Data), fileWritten[crd.Filename]) if err != nil { @@ -500,7 +500,7 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, if hideSecret && m.Head.Kind == "Secret" && m.Head.Version == "v1" { fmt.Fprintf(b, "---\n# Source: %s\n# HIDDEN: The Secret output has been suppressed\n", m.Name) } else { - fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) + fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, strings.TrimRight(m.Content, "\n")) } } else { newDir := outputDir From aca518bd99550a94b3108fde3bd7bff7d96d008c Mon Sep 17 00:00:00 2001 From: waterWang <672684719@qq.com> Date: Sat, 22 Aug 2026 13:56:16 +0800 Subject: [PATCH 2/3] fix(template): trim trailing newline from all rendered manifest paths --- pkg/action/action.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 3c66b9cac..c88749a71 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -473,7 +473,7 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, if strings.TrimSpace(content) == "" { continue } - fmt.Fprintf(b, "---\n# Source: %s\n%s\n", name, content) + fmt.Fprintf(b, "---\n# Source: %s\n%s\n", name, strings.TrimRight(content, "\n")) } return hs, b, "", err } From 36432f74b8b15bb733b3abaec0a1b4bf41d0da8c Mon Sep 17 00:00:00 2001 From: waterWang <672684719@qq.com> Date: Sat, 22 Aug 2026 13:56:18 +0800 Subject: [PATCH 3/3] fix(template): trim trailing newline from hooks and show-only output --- pkg/cmd/template.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/template.go b/pkg/cmd/template.go index 29839b871..db2f629c8 100644 --- a/pkg/cmd/template.go +++ b/pkg/cmd/template.go @@ -127,7 +127,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { continue } if client.OutputDir == "" { - fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) + fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, strings.TrimRight(m.Manifest, "\n")) } else { newDir := client.OutputDir if client.UseReleaseName { @@ -195,7 +195,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } } for _, m := range manifestsToRender { - fmt.Fprintf(out, "---\n%s\n", m) + fmt.Fprintf(out, "---\n%s\n", strings.TrimRight(m, "\n")) } } else { fmt.Fprintf(out, "%s", manifests.String())