diff --git a/generator/chart.go b/generator/chart.go index cb7af79..d8bc0bf 100644 --- a/generator/chart.go +++ b/generator/chart.go @@ -116,14 +116,11 @@ func (chart *HelmChart) SaveTemplates(templateDir string) { fmt.Println(utils.IconFailure, err) os.Exit(1) } - + defer f.Close() if _, err := f.Write(t); err != nil { log.Fatal("error writing template file:", err) } - if err := f.Close(); err != nil { - log.Fatal("error closing template file:", err) - } } } diff --git a/generator/converter.go b/generator/converter.go index 24e2481..77ceb73 100644 --- a/generator/converter.go +++ b/generator/converter.go @@ -630,10 +630,8 @@ func writeContent(path string, content []byte) { fmt.Println(utils.IconFailure, err) os.Exit(1) } + defer f.Close() defer func() { - if err := f.Close(); err != nil { - log.Fatal(err) - } if _, err := f.Write(content); err != nil { log.Fatal(err) } diff --git a/generator/tools_test.go b/generator/tools_test.go index 2395411..66d586e 100644 --- a/generator/tools_test.go +++ b/generator/tools_test.go @@ -49,6 +49,7 @@ func internalCompileTest(t *testing.T, options ...string) string { ChartVersion: chartVersion, } if err := Convert(convertOptions, "compose.yml"); err != nil { + log.Printf("Failed to convert: %s", err) return err.Error() }