Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Jasoet] Enable Support for Yaml Config #5

Merged
merged 6 commits into from
Sep 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Jasoet] Change config loader logic
  • Loading branch information
jasoet committed Sep 25, 2019
commit 4dfb872d79b88ed520dd3253dbe3b46460ef8ddd
15 changes: 6 additions & 9 deletions internal/app/service/infra/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,17 @@ func load() ProctorConfig {
fang := viper.New()

fang.SetEnvPrefix("PROCTOR")
fang.SetEnvKeyReplacer(strings.NewReplacer(".","_"))
fang.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
fang.AutomaticEnv()

fang.SetConfigName("config")
fang.AddConfigPath(".")
fang.AddConfigPath("$HOME/.proctor")
value, available := os.LookupEnv("CONFIG_LOCATION")
if available == true {
fang.SetConfigName("config")
fang.AddConfigPath("$HOME/.proctor")
if available {
fang.AddConfigPath(value)
fang.AddConfigPath(".")
err := fang.ReadInConfig()
if err != nil {
panic(fmt.Errorf("Fatal error config file: %s \n", err))
}
}
_ = fang.ReadInConfig()

proctorConfig := ProctorConfig{
viper: fang,
Expand Down