Fix the compose detection
This commit is contained in:
16
main.go
16
main.go
@@ -19,15 +19,14 @@ var AppName = "MyApp"
|
|||||||
var Version = "master" // set at build time to the git version/tag
|
var Version = "master" // set at build time to the git version/tag
|
||||||
var ChartsDir = "chart"
|
var ChartsDir = "chart"
|
||||||
|
|
||||||
func findComposeFile() {
|
func findComposeFile() bool {
|
||||||
for _, file := range composeFiles {
|
for _, file := range composeFiles {
|
||||||
if _, err := os.Stat(file); err == nil {
|
if _, err := os.Stat(file); err == nil {
|
||||||
ComposeFile = file
|
ComposeFile = file
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("No compose file found in %s\n", composeFiles)
|
return false
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectGitVersion() (string, error) {
|
func detectGitVersion() (string, error) {
|
||||||
@@ -81,7 +80,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// flags
|
// flags
|
||||||
findComposeFile()
|
composeFound := findComposeFile()
|
||||||
|
|
||||||
flag.StringVar(&ChartsDir, "chart-dir", ChartsDir, "set the chart directory")
|
flag.StringVar(&ChartsDir, "chart-dir", ChartsDir, "set the chart directory")
|
||||||
flag.StringVar(&ComposeFile, "compose", ComposeFile, "set the compose file to parse")
|
flag.StringVar(&ComposeFile, "compose", ComposeFile, "set the compose file to parse")
|
||||||
flag.StringVar(&AppName, "appname", helm.GetProjectName(), "set the helm chart app name")
|
flag.StringVar(&AppName, "appname", helm.GetProjectName(), "set the helm chart app name")
|
||||||
@@ -96,6 +96,12 @@ func main() {
|
|||||||
os.Exit(0)
|
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)
|
dirname := filepath.Join(ChartsDir, AppName)
|
||||||
if _, err := os.Stat(dirname); err == nil && !*force {
|
if _, err := os.Stat(dirname); err == nil && !*force {
|
||||||
response := ""
|
response := ""
|
||||||
|
Reference in New Issue
Block a user