summaryrefslogtreecommitdiffstats
path: root/utils/config.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-09-03 11:08:25 -0400
committerCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-09-03 17:08:25 +0200
commitb98ef658ad217fafe98af088f516746860b2a7b8 (patch)
treebbed37f05ecc6533c4e49df3bd0f661417b49176 /utils/config.go
parent72560311a27bb957576416739cca5e71c8665980 (diff)
downloadchat-b98ef658ad217fafe98af088f516746860b2a7b8.tar.gz
chat-b98ef658ad217fafe98af088f516746860b2a7b8.tar.bz2
chat-b98ef658ad217fafe98af088f516746860b2a7b8.zip
MM-11720: disable loading plugin specific config from the environment (#9334)
There are numerous issues here, including some non-determinism in the viper library (fixable) and some annoying behaviour regarding periods in keys, often used by plugin ids (fix unknown). Let's defer the handling of same until we can get our config loading library to do what we need it to do vs. having to hack around viper all the time.
Diffstat (limited to 'utils/config.go')
-rw-r--r--utils/config.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/utils/config.go b/utils/config.go
index 3ce2215a3..7e5a42faa 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -247,6 +247,16 @@ func ReadConfig(r io.Reader, allowEnvironmentOverrides bool) (*model.Config, map
var config model.Config
unmarshalErr := v.Unmarshal(&config)
+ // https://github.com/spf13/viper/issues/324
+ // https://github.com/spf13/viper/issues/348
+ if unmarshalErr == nil {
+ config.PluginSettings.Plugins = make(map[string]map[string]interface{})
+ unmarshalErr = v.UnmarshalKey("pluginsettings.plugins", &config.PluginSettings.Plugins)
+ }
+ if unmarshalErr == nil {
+ config.PluginSettings.PluginStates = make(map[string]*model.PluginState)
+ unmarshalErr = v.UnmarshalKey("pluginsettings.pluginstates", &config.PluginSettings.PluginStates)
+ }
envConfig := v.EnvSettings()
@@ -274,6 +284,10 @@ func newViper(allowEnvironmentOverrides bool) *viper.Viper {
defaults := getDefaultsFromStruct(model.Config{})
for key, value := range defaults {
+ if key == "PluginSettings.Plugins" || key == "PluginSettings.PluginStates" {
+ continue
+ }
+
v.SetDefault(key, value)
}