From b9e91d56aae23644ab19526f2029ec9bb3dd5993 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Wed, 2 Feb 2022 10:02:35 +0100 Subject: [PATCH] Allow different docker-compose extensions --- main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 37efac2..870cc02 100644 --- a/main.go +++ b/main.go @@ -13,11 +13,23 @@ import ( "strings" ) -var ComposeFile = "docker-compose.yaml" +var composeFiles = []string{"docker-compose.yaml", "docker-compose.yml"} +var ComposeFile = "" var AppName = "MyApp" var Version = "master" // set at build time to the git version/tag var ChartsDir = "chart" +func findComposeFile() { + for _, file := range composeFiles { + if _, err := os.Stat(file); err == nil { + ComposeFile = file + return + } + } + fmt.Printf("No compose file found in %s\n", composeFiles) + os.Exit(1) +} + func detectGitVersion() (string, error) { defaulVersion := "0.0.1" // Check if .git directory exists @@ -69,6 +81,7 @@ func main() { } // flags + 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")