summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-06-16 17:05:23 -0400
committerChristopher Speller <crspeller@gmail.com>2015-06-16 17:05:23 -0400
commitd4c7e8e2653893d885b581f3fd98d31b84fe0ef4 (patch)
tree99353cf56a27e5a34696ecd138207fc1170514d8
parent7b49194d9eda3005e7bd97120dd19224ffff6c8c (diff)
downloadchat-d4c7e8e2653893d885b581f3fd98d31b84fe0ef4.tar.gz
chat-d4c7e8e2653893d885b581f3fd98d31b84fe0ef4.tar.bz2
chat-d4c7e8e2653893d885b581f3fd98d31b84fe0ef4.zip
Allow for setting of domain with enviroment variable
-rw-r--r--utils/config.go5
-rw-r--r--utils/config_test.go15
2 files changed, 20 insertions, 0 deletions
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()
+ }
+}