Mono repo -> Master (#22553)
Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
Этот коммит содержится в:
@@ -11,7 +11,7 @@ import (
|
||||
"net/http"
|
||||
timePkg "time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
var hookNameToId map[string]int = make(map[string]int)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/utils"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/utils"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
var ErrNotFound = errors.New("Item not found")
|
||||
@@ -109,9 +109,36 @@ func scanSearchPath(path string) ([]*model.BundleInfo, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
var pluginIDBlocklist = map[string]bool{
|
||||
"playbooks": true,
|
||||
"com.mattermost.plugin-incident-response": true,
|
||||
"com.mattermost.plugin-incident-management": true,
|
||||
"focalboard": true,
|
||||
}
|
||||
|
||||
func PluginIDIsBlocked(id string) bool {
|
||||
_, ok := pluginIDBlocklist[id]
|
||||
return ok
|
||||
}
|
||||
|
||||
// Returns a list of all plugins within the environment.
|
||||
func (env *Environment) Available() ([]*model.BundleInfo, error) {
|
||||
return scanSearchPath(env.pluginDir)
|
||||
rawList, err := scanSearchPath(env.pluginDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Filter any plugins that match the blocklist
|
||||
filteredList := make([]*model.BundleInfo, 0, len(rawList))
|
||||
for _, bundleInfo := range rawList {
|
||||
if PluginIDIsBlocked(bundleInfo.Manifest.Id) {
|
||||
env.logger.Debug("Plugin ignored by blocklist", mlog.String("plugin_id", bundleInfo.Manifest.Id))
|
||||
} else {
|
||||
filteredList = append(filteredList, bundleInfo)
|
||||
}
|
||||
}
|
||||
|
||||
return filteredList, nil
|
||||
}
|
||||
|
||||
// Returns a list of prepackaged plugins available in the local prepackaged_plugins folder.
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
func TestAvailablePlugins(t *testing.T) {
|
||||
@@ -21,8 +22,10 @@ func TestAvailablePlugins(t *testing.T) {
|
||||
os.RemoveAll(dir)
|
||||
})
|
||||
|
||||
testLogger, _ := mlog.NewLogger()
|
||||
env := Environment{
|
||||
pluginDir: dir,
|
||||
logger: testLogger,
|
||||
}
|
||||
|
||||
t.Run("Should be able to load available plugins", func(t *testing.T) {
|
||||
@@ -70,4 +73,26 @@ func TestAvailablePlugins(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Len(t, bundles, 0)
|
||||
})
|
||||
|
||||
t.Run("Should not load bundles on blocklist", func(t *testing.T) {
|
||||
bundle := model.BundleInfo{
|
||||
Manifest: &model.Manifest{
|
||||
Id: "playbooks",
|
||||
Version: "1",
|
||||
},
|
||||
}
|
||||
err := os.Mkdir(filepath.Join(dir, "plugin4"), 0700)
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(filepath.Join(dir, "plugin4"))
|
||||
|
||||
path := filepath.Join(dir, "plugin4", "plugin.json")
|
||||
manifestJSON, jsonErr := json.Marshal(bundle.Manifest)
|
||||
require.NoError(t, jsonErr)
|
||||
err = os.WriteFile(path, manifestJSON, 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
bundles, err := env.Available()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, bundles, 0)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
type hclogAdapter struct {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/utils"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/utils"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
func TestPluginHealthCheck(t *testing.T) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"net/http"
|
||||
timePkg "time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
type hijackedResponse struct {
|
||||
|
||||
@@ -453,7 +453,7 @@ import (
|
||||
"net/http"
|
||||
timePkg "time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
)
|
||||
|
||||
@@ -495,7 +495,7 @@ import (
|
||||
"net/http"
|
||||
timePkg "time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ package scheduler
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/jobs"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/jobs"
|
||||
)
|
||||
|
||||
const schedFreq = 24 * time.Hour
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/v6/jobs"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/jobs"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
type AppIface interface {
|
||||
|
||||
@@ -18,9 +18,9 @@ import (
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
type supervisor struct {
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/utils"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/utils"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
|
||||
)
|
||||
|
||||
func TestSupervisor(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user