config.go: parse config file before default

Closes https://gitlab.com/commento/commento/issues/187
This commit is contained in:
Adhityaa Chandrasekar
2019-08-21 21:07:44 -07:00
parent 9538c9036e
commit 52f8df5183
4 changed files with 15 additions and 13 deletions

View File

@@ -58,6 +58,12 @@ func configParse() error {
"GITLAB_SECRET": "",
}
if os.Getenv("COMMENTO_CONFIG_FILE") != "" {
if err := configFileLoad(os.Getenv("COMMENTO_CONFIG_FILE")); err != nil {
return err
}
}
for key, value := range defaults {
if os.Getenv("COMMENTO_"+key) == "" {
os.Setenv(key, value)
@@ -66,12 +72,6 @@ func configParse() error {
}
}
if os.Getenv("CONFIG_FILE") != "" {
if err := configFileLoad(os.Getenv("CONFIG_FILE")); err != nil {
return err
}
}
// Mandatory config parameters
for _, env := range []string{"POSTGRES", "PORT", "ORIGIN", "FORBID_NEW_OWNERS", "MAX_IDLE_PG_CONNECTIONS"} {
if os.Getenv(env) == "" {