diff --git a/horusec-cli/cmd/horusec/main.go b/horusec-cli/cmd/horusec/main.go index 4d7f611f7..12eadffb1 100644 --- a/horusec-cli/cmd/horusec/main.go +++ b/horusec-cli/cmd/horusec/main.go @@ -15,8 +15,8 @@ package main import ( - "fmt" "os" + "path" "github.com/ZupIT/horusec/development-kit/pkg/utils/logger" "github.com/ZupIT/horusec/horusec-cli/cmd/horusec/start" @@ -27,6 +27,7 @@ import ( ) var LogLevel = logger.InfoLevel.String() +var ConfigPath = "./horusec-config.json" var configs *config.Config var rootCmd = &cobra.Command{ @@ -74,8 +75,8 @@ func ExecuteCobra() { } func setConfigsData() { - path, _ := os.Getwd() - configs.ConfigFilePath = fmt.Sprintf("%s/horusec-config.json", path) + configs.ConfigFilePath = getConfigPath() + configs.SetConfigsFromViper() configs.SetConfigsFromEnvironments() } @@ -83,3 +84,13 @@ func setConfigsData() { func initConfig() { logger.SetLogLevel(LogLevel) } + +func getConfigPath() string { + isAbs := path.IsAbs(ConfigPath) + if isAbs { + return ConfigPath + } + + currentDir, _ := os.Getwd() + return path.Join(currentDir, ConfigPath) +}