fix(template): trim trailing newline from rendered manifests to match v4.1.x stdout output

pull/32566/head
waterWang 3 weeks ago
parent e9b85e4de1
commit 4e81adb8d7

@ -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

Loading…
Cancel
Save