diff --git a/pkg/action/action.go b/pkg/action/action.go index e93d6181f..9306bcaa2 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 } @@ -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 } @@ -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 diff --git a/pkg/cmd/template.go b/pkg/cmd/template.go index 5645ab33d..db497977a 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())