summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-10-26 13:21:35 -0400
committerGitHub <noreply@github.com>2017-10-26 13:21:35 -0400
commita0bfd2885d03e3f9fb6b3cdd6ba60eea93c848b2 (patch)
tree376ca7c1b969b6d7efbf5fb608d9afc157452c39
parent6f6005c617799e2f51071f43af718e5d4e77492b (diff)
downloadchat-a0bfd2885d03e3f9fb6b3cdd6ba60eea93c848b2.tar.gz
chat-a0bfd2885d03e3f9fb6b3cdd6ba60eea93c848b2.tar.bz2
chat-a0bfd2885d03e3f9fb6b3cdd6ba60eea93c848b2.zip
Add config setting to configure plugins directory (#7725)
-rw-r--r--api4/plugin_test.go11
-rw-r--r--cmd/platform/server.go2
-rw-r--r--config/default.json4
-rw-r--r--model/config.go13
4 files changed, 22 insertions, 8 deletions
diff --git a/api4/plugin_test.go b/api4/plugin_test.go
index 48ee4fb74..0c39b2a89 100644
--- a/api4/plugin_test.go
+++ b/api4/plugin_test.go
@@ -5,6 +5,7 @@ package api4
import (
"bytes"
+ "encoding/json"
"io/ioutil"
"os"
"testing"
@@ -29,11 +30,16 @@ func TestPlugin(t *testing.T) {
enablePlugins := *th.App.Config().PluginSettings.Enable
enableUploadPlugins := *th.App.Config().PluginSettings.EnableUploads
+ statesJson, _ := json.Marshal(th.App.Config().PluginSettings.PluginStates)
+ states := map[string]*model.PluginState{}
+ json.Unmarshal(statesJson, &states)
defer func() {
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = enablePlugins
*cfg.PluginSettings.EnableUploads = enableUploadPlugins
+ cfg.PluginSettings.PluginStates = states
})
+ th.App.SaveConfig(th.App.Config(), false)
}()
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
@@ -101,11 +107,6 @@ func TestPlugin(t *testing.T) {
assert.False(t, found)
- states := th.App.Config().PluginSettings.PluginStates
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.PluginSettings.PluginStates = states })
- }()
-
// Successful activate
ok, resp := th.SystemAdminClient.ActivatePlugin(manifest.Id)
CheckNoError(t, resp)
diff --git a/cmd/platform/server.go b/cmd/platform/server.go
index d0065245f..05e527462 100644
--- a/cmd/platform/server.go
+++ b/cmd/platform/server.go
@@ -74,7 +74,7 @@ func runServer(configFileLocation string) {
a.InitBuiltInPlugins()
if webappDir, ok := utils.FindDir(model.CLIENT_DIR); ok {
- a.InitPlugins("plugins", webappDir+"/plugins")
+ a.InitPlugins(*a.Config().PluginSettings.Directory, webappDir+"/plugins")
} else {
l4g.Error("Unable to find webapp directory, could not initialize plugins")
}
diff --git a/config/default.json b/config/default.json
index 33b52022a..d0688f765 100644
--- a/config/default.json
+++ b/config/default.json
@@ -335,6 +335,8 @@
"PluginSettings": {
"Enable": true,
"EnableUploads": false,
- "Plugins": {}
+ "Directory": "./plugins",
+ "Plugins": {},
+ "PluginStates": {}
}
}
diff --git a/model/config.go b/model/config.go
index f24208754..9871a13b4 100644
--- a/model/config.go
+++ b/model/config.go
@@ -147,6 +147,8 @@ const (
DATA_RETENTION_SETTINGS_DEFAULT_MESSAGE_RETENTION_DAYS = 365
DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS = 365
DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME = "02:00"
+
+ PLUGIN_SETTINGS_DEFAULT_DIRECTORY = "./plugins"
)
type ServiceSettings struct {
@@ -515,6 +517,7 @@ type PluginState struct {
type PluginSettings struct {
Enable *bool
EnableUploads *bool
+ Directory *string
Plugins map[string]interface{}
PluginStates map[string]*PluginState
}
@@ -1470,7 +1473,15 @@ func (o *Config) SetDefaults() {
}
if o.PluginSettings.EnableUploads == nil {
- o.PluginSettings.Enable = NewBool(false)
+ o.PluginSettings.EnableUploads = NewBool(false)
+ }
+
+ if o.PluginSettings.Directory == nil {
+ o.PluginSettings.Directory = NewString(PLUGIN_SETTINGS_DEFAULT_DIRECTORY)
+ }
+
+ if *o.PluginSettings.Directory == "" {
+ *o.PluginSettings.Directory = PLUGIN_SETTINGS_DEFAULT_DIRECTORY
}
if o.PluginSettings.Plugins == nil {