From 9aec646ab201a4b3da21667678eeee96b7a8a68d Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Wed, 2 Feb 2022 10:30:32 +0100 Subject: [PATCH] Fix the compose detection --- main.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 870cc02..5b3faab 100644 --- a/main.go +++ b/main.go @@ -19,15 +19,14 @@ var AppName = "MyApp" var Version = "master" // set at build time to the git version/tag var ChartsDir = "chart" -func findComposeFile() { +func findComposeFile() bool { for _, file := range composeFiles { if _, err := os.Stat(file); err == nil { ComposeFile = file - return + return true } } - fmt.Printf("No compose file found in %s\n", composeFiles) - os.Exit(1) + return false } func detectGitVersion() (string, error) { @@ -81,7 +80,8 @@ func main() { } // flags - findComposeFile() + composeFound := findComposeFile() + flag.StringVar(&ChartsDir, "chart-dir", ChartsDir, "set the chart directory") flag.StringVar(&ComposeFile, "compose", ComposeFile, "set the compose file to parse") flag.StringVar(&AppName, "appname", helm.GetProjectName(), "set the helm chart app name") @@ -96,6 +96,12 @@ func main() { os.Exit(0) } + _, err := os.Stat(ComposeFile) + if !composeFound && err != nil { + fmt.Println("No compose file found") + os.Exit(1) + } + dirname := filepath.Join(ChartsDir, AppName) if _, err := os.Stat(dirname); err == nil && !*force { response := ""