Add config setting to configure plugins directory (#7725)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6f6005c617
Коммит
a0bfd2885d
@@ -5,6 +5,7 @@ package api4
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -29,11 +30,16 @@ func TestPlugin(t *testing.T) {
|
|||||||
|
|
||||||
enablePlugins := *th.App.Config().PluginSettings.Enable
|
enablePlugins := *th.App.Config().PluginSettings.Enable
|
||||||
enableUploadPlugins := *th.App.Config().PluginSettings.EnableUploads
|
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() {
|
defer func() {
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||||
*cfg.PluginSettings.Enable = enablePlugins
|
*cfg.PluginSettings.Enable = enablePlugins
|
||||||
*cfg.PluginSettings.EnableUploads = enableUploadPlugins
|
*cfg.PluginSettings.EnableUploads = enableUploadPlugins
|
||||||
|
cfg.PluginSettings.PluginStates = states
|
||||||
})
|
})
|
||||||
|
th.App.SaveConfig(th.App.Config(), false)
|
||||||
}()
|
}()
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||||
*cfg.PluginSettings.Enable = true
|
*cfg.PluginSettings.Enable = true
|
||||||
@@ -101,11 +107,6 @@ func TestPlugin(t *testing.T) {
|
|||||||
|
|
||||||
assert.False(t, found)
|
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
|
// Successful activate
|
||||||
ok, resp := th.SystemAdminClient.ActivatePlugin(manifest.Id)
|
ok, resp := th.SystemAdminClient.ActivatePlugin(manifest.Id)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func runServer(configFileLocation string) {
|
|||||||
a.InitBuiltInPlugins()
|
a.InitBuiltInPlugins()
|
||||||
|
|
||||||
if webappDir, ok := utils.FindDir(model.CLIENT_DIR); ok {
|
if webappDir, ok := utils.FindDir(model.CLIENT_DIR); ok {
|
||||||
a.InitPlugins("plugins", webappDir+"/plugins")
|
a.InitPlugins(*a.Config().PluginSettings.Directory, webappDir+"/plugins")
|
||||||
} else {
|
} else {
|
||||||
l4g.Error("Unable to find webapp directory, could not initialize plugins")
|
l4g.Error("Unable to find webapp directory, could not initialize plugins")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,6 +335,8 @@
|
|||||||
"PluginSettings": {
|
"PluginSettings": {
|
||||||
"Enable": true,
|
"Enable": true,
|
||||||
"EnableUploads": false,
|
"EnableUploads": false,
|
||||||
"Plugins": {}
|
"Directory": "./plugins",
|
||||||
|
"Plugins": {},
|
||||||
|
"PluginStates": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,6 +147,8 @@ const (
|
|||||||
DATA_RETENTION_SETTINGS_DEFAULT_MESSAGE_RETENTION_DAYS = 365
|
DATA_RETENTION_SETTINGS_DEFAULT_MESSAGE_RETENTION_DAYS = 365
|
||||||
DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS = 365
|
DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS = 365
|
||||||
DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME = "02:00"
|
DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME = "02:00"
|
||||||
|
|
||||||
|
PLUGIN_SETTINGS_DEFAULT_DIRECTORY = "./plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServiceSettings struct {
|
type ServiceSettings struct {
|
||||||
@@ -515,6 +517,7 @@ type PluginState struct {
|
|||||||
type PluginSettings struct {
|
type PluginSettings struct {
|
||||||
Enable *bool
|
Enable *bool
|
||||||
EnableUploads *bool
|
EnableUploads *bool
|
||||||
|
Directory *string
|
||||||
Plugins map[string]interface{}
|
Plugins map[string]interface{}
|
||||||
PluginStates map[string]*PluginState
|
PluginStates map[string]*PluginState
|
||||||
}
|
}
|
||||||
@@ -1470,7 +1473,15 @@ func (o *Config) SetDefaults() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if o.PluginSettings.EnableUploads == nil {
|
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 {
|
if o.PluginSettings.Plugins == nil {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user