Skip to content

Commit

Permalink
load config from file only if env is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
nawaitesidah committed Jul 21, 2018
1 parent 9032be9 commit 4df7f29
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func loadConfig() (string, string, string) {
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()

host, user, token := viper.GetString("core.host"), viper.GetString("core.user"), viper.GetString("core.token")
if host != "" && user != "" && token != "" {
return host, user, token
}

if _, ok := viper.ReadInConfig().(viper.ConfigFileNotFoundError); ok {
if err := config.New(path.Join(confpath, "lab.hcl"), os.Stdin); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 4df7f29

Please sign in to comment.