Merge pull request #15 from mattermost/enviroment-override

Allow for setting of domain with enviroment variable
This commit is contained in:
Corey Hulen
2015-06-16 13:50:22 -08:00
2 changed files with 20 additions and 0 deletions

View File

@@ -217,6 +217,11 @@ func LoadConfig(fileName string) {
panic("Error decoding configuration " + err.Error())
}
// Grabs the domain from enviroment variable if not in configuration
if config.ServiceSettings.Domain == "" {
config.ServiceSettings.Domain = os.Getenv("MATTERMOST_DOMAIN")
}
configureLog(config.LogSettings)
Cfg = &config

View File

@@ -4,9 +4,24 @@
package utils
import (
"os"
"testing"
)
func TestConfig(t *testing.T) {
LoadConfig("config.json")
}
func TestEnvOverride(t *testing.T) {
os.Setenv("MATTERMOST_DOMAIN", "testdomain.com")
LoadConfig("config_docker.json")
if Cfg.ServiceSettings.Domain != "testdomain.com" {
t.Fail()
}
LoadConfig("config.json")
if Cfg.ServiceSettings.Domain == "testdomain.com" {
t.Fail()
}
}