From e9040749bdcb1d1bcb7fdd199e27fbe69c1f07ec Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 16 Jun 2015 17:05:23 -0400 Subject: Allow for setting of domain with enviroment variable --- utils/config.go | 5 +++++ utils/config_test.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'utils') diff --git a/utils/config.go b/utils/config.go index 76e6060be..745887c70 100644 --- a/utils/config.go +++ b/utils/config.go @@ -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 diff --git a/utils/config_test.go b/utils/config_test.go index 4d37b4e88..9067dc647 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -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() + } +} -- cgit v1.2.3-1-g7c22