Skip to content

Commit

Permalink
fix config datapath issue on docker
Browse files Browse the repository at this point in the history
  • Loading branch information
domino14 committed Nov 9, 2024
1 parent 6c2cf7e commit ccc90a8
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ func (c *Config) Load(args []string) error {
c.Viper = *viper.New()
c.SetConfigName("config")
c.SetConfigType("yaml")
// If no config file is found:
c.SetEnvPrefix("macondo")
// allow env vars to be specified with `_` instead of `-`
replacer := strings.NewReplacer("-", "_")
c.SetEnvKeyReplacer(replacer)

// Explicitly bind env vars.
c.BindEnv(ConfigDataPath)
c.BindEnv(ConfigDefaultLexicon)
c.BindEnv(ConfigDefaultLetterDistribution)
c.BindEnv(ConfigTtableMemFraction)
c.BindEnv(ConfigLambdaFunctionName)
c.BindEnv(ConfigNatsURL)
c.BindEnv(ConfigWolgesAwsmUrl)
c.BindEnv(ConfigDebug)
c.BindEnv(ConfigKWGPathPrefix)
c.BindEnv(ConfigCPUProfile)
c.BindEnv(ConfigMEMProfile)
c.BindEnv(ConfigDefaultBoardLayout)

cfgdir, err := os.UserConfigDir()
if err != nil {
Expand Down Expand Up @@ -97,24 +116,6 @@ func (c *Config) Load(args []string) error {
c.Set(ConfigDataPath, "./data")
}
}
c.SetEnvPrefix("macondo")
// allow env vars to be specified with `_` instead of `-`
replacer := strings.NewReplacer("-", "_")
c.SetEnvKeyReplacer(replacer)

// Explicitly bind env vars.
c.BindEnv(ConfigDataPath)
c.BindEnv(ConfigDefaultLexicon)
c.BindEnv(ConfigDefaultLetterDistribution)
c.BindEnv(ConfigTtableMemFraction)
c.BindEnv(ConfigLambdaFunctionName)
c.BindEnv(ConfigNatsURL)
c.BindEnv(ConfigWolgesAwsmUrl)
c.BindEnv(ConfigDebug)
c.BindEnv(ConfigKWGPathPrefix)
c.BindEnv(ConfigCPUProfile)
c.BindEnv(ConfigMEMProfile)
c.BindEnv(ConfigDefaultBoardLayout)

c.SetDefault(ConfigDataPath, "./data") // will be fixed by toAbsPath below if unspecified.
c.SetDefault(ConfigDefaultLexicon, "NWL23")
Expand Down

0 comments on commit ccc90a8

Please sign in to comment.