Skip to content

Commit

Permalink
Fix default corgi compose file path
Browse files Browse the repository at this point in the history
  • Loading branch information
Andriiklymiuk committed Oct 31, 2022
1 parent e8b01a2 commit c5568a2
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@ func GetCorgiServices(cobra *cobra.Command) (*CorgiCompose, error) {
pathToCorgiComposeFile = filenameFlag
}
if pathToCorgiComposeFile == "" {
chosenCorgiPath, err := getCorgiConfigFromAlert()
if err != nil || chosenCorgiPath == "" {
pathToCorgiComposeFile = "corgi-compose.yml"
} else {
pathToCorgiComposeFile = chosenCorgiPath
chosenPathToCorgiCompose, err := getCorgiConfigFilePath()
if err != nil {
return nil, err
}
pathToCorgiComposeFile = chosenPathToCorgiCompose
}

describeFlag, err := cobra.Root().Flags().GetBool("describe")
Expand Down Expand Up @@ -268,6 +267,29 @@ func IsServiceIncludedInFlag(services []string, serviceName string) bool {
return isIncluded
}

func getCorgiConfigFilePath() (string, error) {
defaultCorgiConfigName := "corgi-compose.yml"
corgiComposeExists, err := CheckIfFileExistsInDirectory(
".",
defaultCorgiConfigName,
)
if err != nil {
return "", err
}
if corgiComposeExists {
return defaultCorgiConfigName, nil
}

chosenCorgiPath, err := getCorgiConfigFromAlert()
if err != nil {
return "", err
}
if err != nil || chosenCorgiPath == "" {
return "", err
}
return chosenCorgiPath, nil
}

func getCorgiConfigFromAlert() (string, error) {
var files []string
err := filepath.WalkDir(".", func(path string, directory fs.DirEntry, err error) error {
Expand Down

0 comments on commit c5568a2

Please sign in to comment.