Skip to content

Commit

Permalink
Adding support for root path horusec-config file (#161)
Browse files Browse the repository at this point in the history
* Fixing abs path for horusec-config.json

* Adding config path flag

* Adding inputs package

* Removing uncessary code

* Removing config flag
  • Loading branch information
nathannascimentozup authored Dec 2, 2020
1 parent 1acf85b commit a29ee71
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions horusec-cli/cmd/horusec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -27,6 +27,7 @@ import (
)

var LogLevel = logger.InfoLevel.String()
var ConfigPath = "./horusec-config.json"
var configs *config.Config

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -74,12 +75,22 @@ func ExecuteCobra() {
}

func setConfigsData() {
path, _ := os.Getwd()
configs.ConfigFilePath = fmt.Sprintf("%s/horusec-config.json", path)
configs.ConfigFilePath = getConfigPath()

configs.SetConfigsFromViper()
configs.SetConfigsFromEnvironments()
}

func initConfig() {
logger.SetLogLevel(LogLevel)
}

func getConfigPath() string {
isAbs := path.IsAbs(ConfigPath)
if isAbs {
return ConfigPath
}

currentDir, _ := os.Getwd()
return path.Join(currentDir, ConfigPath)
}

0 comments on commit a29ee71

Please sign in to comment.