From da260ec15fc4eba4a3cbe0791bd05b410bf75766 Mon Sep 17 00:00:00 2001 From: Torsten Walter Date: Tue, 28 May 2019 17:21:26 +0200 Subject: [PATCH] do not write empty templates to disk Signed-off-by: Torsten Walter --- pkg/action/install.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/action/install.go b/pkg/action/install.go index 1a463e64e..e21de0c91 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -25,6 +25,7 @@ import ( "os" "path" "path/filepath" + "regexp" "sort" "strings" "text/template" @@ -63,6 +64,8 @@ const notesFileSuffix = "NOTES.txt" const defaultDirectoryPermission = 0755 +var whitespaceRegex = regexp.MustCompile(`^\s*$`) + // Install performs an installation operation. type Install struct { cfg *Configuration @@ -369,6 +372,10 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values if outputDir == "" { fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) } else { + // blank template after execution + if whitespaceRegex.MatchString(m.Content) { + continue + } err = writeToFile(outputDir, m.Name, m.Content) if err != nil { return hs, b, "", err