[MM-37664] Remove deprecated Backend field from plugin manifest (#18064)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d447d9b64a
Коммит
cbba2f1cca
@@ -559,7 +559,7 @@ func TestSubmitInteractiveDialog(t *testing.T) {
|
|||||||
func main() {
|
func main() {
|
||||||
plugin.ClientMain(&MyPlugin{})
|
plugin.ClientMain(&MyPlugin{})
|
||||||
}
|
}
|
||||||
`, `{"id": "myplugin", "backend": {"executable": "backend.exe"}}`, "myplugin", th.App, th.Context)
|
`, `{"id": "myplugin", "server": {"executable": "backend.exe"}}`, "myplugin", th.App, th.Context)
|
||||||
|
|
||||||
hooks, err2 := th.App.GetPluginsEnvironment().HooksForPlugin("myplugin")
|
hooks, err2 := th.App.GetPluginsEnvironment().HooksForPlugin("myplugin")
|
||||||
require.NoError(t, err2)
|
require.NoError(t, err2)
|
||||||
@@ -841,7 +841,7 @@ func TestPostActionRelativePluginURL(t *testing.T) {
|
|||||||
func main() {
|
func main() {
|
||||||
plugin.ClientMain(&MyPlugin{})
|
plugin.ClientMain(&MyPlugin{})
|
||||||
}
|
}
|
||||||
`, `{"id": "myplugin", "backend": {"executable": "backend.exe"}}`, "myplugin", th.App, th.Context)
|
`, `{"id": "myplugin", "server": {"executable": "backend.exe"}}`, "myplugin", th.App, th.Context)
|
||||||
|
|
||||||
hooks, err2 := th.App.GetPluginsEnvironment().HooksForPlugin("myplugin")
|
hooks, err2 := th.App.GetPluginsEnvironment().HooksForPlugin("myplugin")
|
||||||
require.NoError(t, err2)
|
require.NoError(t, err2)
|
||||||
@@ -1060,7 +1060,7 @@ func TestDoPluginRequest(t *testing.T) {
|
|||||||
func main() {
|
func main() {
|
||||||
plugin.ClientMain(&MyPlugin{})
|
plugin.ClientMain(&MyPlugin{})
|
||||||
}
|
}
|
||||||
`, `{"id": "myplugin", "backend": {"executable": "backend.exe"}}`, "myplugin", th.App, th.Context)
|
`, `{"id": "myplugin", "server": {"executable": "backend.exe"}}`, "myplugin", th.App, th.Context)
|
||||||
|
|
||||||
hooks, err2 := th.App.GetPluginsEnvironment().HooksForPlugin("myplugin")
|
hooks, err2 := th.App.GetPluginsEnvironment().HooksForPlugin("myplugin")
|
||||||
require.NoError(t, err2)
|
require.NoError(t, err2)
|
||||||
|
|||||||
@@ -691,7 +691,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
|||||||
require.True(t, found, "Cannot find tests folder")
|
require.True(t, found, "Cannot find tests folder")
|
||||||
fullPath := path.Join(testFolder, "manual.test_load_configuration_plugin", "main.go")
|
fullPath := path.Join(testFolder, "manual.test_load_configuration_plugin", "main.go")
|
||||||
|
|
||||||
err = pluginAPIHookTest(t, th, fullPath, "testloadpluginconfig", `{"id": "testloadpluginconfig", "backend": {"executable": "backend.exe"}, "settings_schema": {
|
err = pluginAPIHookTest(t, th, fullPath, "testloadpluginconfig", `{"id": "testloadpluginconfig", "server": {"executable": "backend.exe"}, "settings_schema": {
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"key": "MyStringSetting",
|
"key": "MyStringSetting",
|
||||||
@@ -950,7 +950,7 @@ func TestInstallPlugin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
`,
|
`,
|
||||||
`{"id": "testinstallplugin", "backend": {"executable": "backend.exe"}, "settings_schema": {
|
`{"id": "testinstallplugin", "server": {"executable": "backend.exe"}, "settings_schema": {
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"key": "DownloadURL",
|
"key": "DownloadURL",
|
||||||
@@ -1068,7 +1068,7 @@ func pluginAPIHookTest(t *testing.T, th *TestHelper, fileName string, id string,
|
|||||||
}
|
}
|
||||||
th.App.srv.sqlStore = th.GetSqlStore()
|
th.App.srv.sqlStore = th.GetSqlStore()
|
||||||
setupPluginApiTest(t, code,
|
setupPluginApiTest(t, code,
|
||||||
fmt.Sprintf(`{"id": "%v", "backend": {"executable": "backend.exe"}, "settings_schema": %v}`, id, schema),
|
fmt.Sprintf(`{"id": "%v", "server": {"executable": "backend.exe"}, "settings_schema": %v}`, id, schema),
|
||||||
id, th.App, th.Context)
|
id, th.App, th.Context)
|
||||||
hooks, err := th.App.GetPluginsEnvironment().HooksForPlugin(id)
|
hooks, err := th.App.GetPluginsEnvironment().HooksForPlugin(id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1511,8 +1511,8 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
`{"id": "testplugininterserver", "backend": {"executable": "backend.exe"}}`,
|
`{"id": "testplugininterserver", "server": {"executable": "backend.exe"}}`,
|
||||||
`{"id": "testplugininterclient", "backend": {"executable": "backend.exe"}}`,
|
`{"id": "testplugininterclient", "server": {"executable": "backend.exe"}}`,
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"testplugininterserver",
|
"testplugininterserver",
|
||||||
@@ -1573,7 +1573,7 @@ func TestApiMetrics(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
utils.CompileGo(t, code, backend)
|
utils.CompileGo(t, code, backend)
|
||||||
ioutil.WriteFile(filepath.Join(pluginDir, pluginID, "plugin.json"), []byte(`{"id": "`+pluginID+`", "backend": {"executable": "backend.exe"}}`), 0600)
|
ioutil.WriteFile(filepath.Join(pluginDir, pluginID, "plugin.json"), []byte(`{"id": "`+pluginID+`", "server": {"executable": "backend.exe"}}`), 0600)
|
||||||
|
|
||||||
// Don't care about these mocks
|
// Don't care about these mocks
|
||||||
metricsMock.On("ObservePluginHookDuration", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return()
|
metricsMock.On("ObservePluginHookDuration", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return()
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func SetAppEnvironmentWithPlugins(t *testing.T, pluginCode []string, app *App, a
|
|||||||
backend := filepath.Join(pluginDir, pluginID, "backend.exe")
|
backend := filepath.Join(pluginDir, pluginID, "backend.exe")
|
||||||
utils.CompileGo(t, code, backend)
|
utils.CompileGo(t, code, backend)
|
||||||
|
|
||||||
ioutil.WriteFile(filepath.Join(pluginDir, pluginID, "plugin.json"), []byte(`{"id": "`+pluginID+`", "backend": {"executable": "backend.exe"}}`), 0600)
|
ioutil.WriteFile(filepath.Join(pluginDir, pluginID, "plugin.json"), []byte(`{"id": "`+pluginID+`", "server": {"executable": "backend.exe"}}`), 0600)
|
||||||
_, _, activationErr := env.Activate(pluginID)
|
_, _, activationErr := env.Activate(pluginID)
|
||||||
pluginIDs = append(pluginIDs, pluginID)
|
pluginIDs = append(pluginIDs, pluginID)
|
||||||
activationErrors = append(activationErrors, activationErr)
|
activationErrors = append(activationErrors, activationErr)
|
||||||
@@ -1083,7 +1083,7 @@ func TestHookMetrics(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
utils.CompileGo(t, code, backend)
|
utils.CompileGo(t, code, backend)
|
||||||
ioutil.WriteFile(filepath.Join(pluginDir, pluginID, "plugin.json"), []byte(`{"id": "`+pluginID+`", "backend": {"executable": "backend.exe"}}`), 0600)
|
ioutil.WriteFile(filepath.Join(pluginDir, pluginID, "plugin.json"), []byte(`{"id": "`+pluginID+`", "server": {"executable": "backend.exe"}}`), 0600)
|
||||||
|
|
||||||
// Setup mocks before activating
|
// Setup mocks before activating
|
||||||
metricsMock.On("ObservePluginHookDuration", pluginID, "Implemented", true, mock.Anything).Return()
|
metricsMock.On("ObservePluginHookDuration", pluginID, "Implemented", true, mock.Anything).Return()
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func TestCreatePostDeduplicate(t *testing.T) {
|
|||||||
func main() {
|
func main() {
|
||||||
plugin.ClientMain(&MyPlugin{})
|
plugin.ClientMain(&MyPlugin{})
|
||||||
}
|
}
|
||||||
`, `{"id": "testrejectfirstpost", "backend": {"executable": "backend.exe"}}`, "testrejectfirstpost", th.App, th.Context)
|
`, `{"id": "testrejectfirstpost", "server": {"executable": "backend.exe"}}`, "testrejectfirstpost", th.App, th.Context)
|
||||||
|
|
||||||
pendingPostId := model.NewId()
|
pendingPostId := model.NewId()
|
||||||
post, err := th.App.CreatePostAsUser(th.Context, &model.Post{
|
post, err := th.App.CreatePostAsUser(th.Context, &model.Post{
|
||||||
@@ -128,7 +128,7 @@ func TestCreatePostDeduplicate(t *testing.T) {
|
|||||||
func main() {
|
func main() {
|
||||||
plugin.ClientMain(&MyPlugin{})
|
plugin.ClientMain(&MyPlugin{})
|
||||||
}
|
}
|
||||||
`, `{"id": "testdelayfirstpost", "backend": {"executable": "backend.exe"}}`, "testdelayfirstpost", th.App, th.Context)
|
`, `{"id": "testdelayfirstpost", "server": {"executable": "backend.exe"}}`, "testdelayfirstpost", th.App, th.Context)
|
||||||
|
|
||||||
var post *model.Post
|
var post *model.Post
|
||||||
pendingPostId := model.NewId()
|
pendingPostId := model.NewId()
|
||||||
|
|||||||
@@ -176,9 +176,6 @@ type Manifest struct {
|
|||||||
// Server defines the server-side portion of your plugin.
|
// Server defines the server-side portion of your plugin.
|
||||||
Server *ManifestServer `json:"server,omitempty" yaml:"server,omitempty"`
|
Server *ManifestServer `json:"server,omitempty" yaml:"server,omitempty"`
|
||||||
|
|
||||||
// Backend is a deprecated flag for defining the server-side portion of your plugin. Going forward, use Server instead.
|
|
||||||
Backend *ManifestServer `json:"backend,omitempty" yaml:"backend,omitempty"`
|
|
||||||
|
|
||||||
// If your plugin extends the web app, you'll need to define webapp.
|
// If your plugin extends the web app, you'll need to define webapp.
|
||||||
Webapp *ManifestWebapp `json:"webapp,omitempty" yaml:"webapp,omitempty"`
|
Webapp *ManifestWebapp `json:"webapp,omitempty" yaml:"webapp,omitempty"`
|
||||||
|
|
||||||
@@ -278,11 +275,6 @@ func (m *Manifest) ClientManifest() *Manifest {
|
|||||||
func (m *Manifest) GetExecutableForRuntime(goOs, goArch string) string {
|
func (m *Manifest) GetExecutableForRuntime(goOs, goArch string) string {
|
||||||
server := m.Server
|
server := m.Server
|
||||||
|
|
||||||
// Support the deprecated backend parameter.
|
|
||||||
if server == nil {
|
|
||||||
server = m.Backend
|
|
||||||
}
|
|
||||||
|
|
||||||
if server == nil {
|
if server == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -301,7 +293,7 @@ func (m *Manifest) GetExecutableForRuntime(goOs, goArch string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manifest) HasServer() bool {
|
func (m *Manifest) HasServer() bool {
|
||||||
return m.Server != nil || m.Backend != nil
|
return m.Server != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manifest) HasWebapp() bool {
|
func (m *Manifest) HasWebapp() bool {
|
||||||
|
|||||||
@@ -707,44 +707,6 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
"amd64",
|
"amd64",
|
||||||
"path/to/executable",
|
"path/to/executable",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"deprecated backend field, ignored since server present",
|
|
||||||
&Manifest{
|
|
||||||
Server: &ManifestServer{
|
|
||||||
Executables: map[string]string{
|
|
||||||
"linux-amd64": "linux-amd64/path/to/executable",
|
|
||||||
"darwin-amd64": "darwin-amd64/path/to/executable",
|
|
||||||
"windows-amd64": "windows-amd64/path/to/executable",
|
|
||||||
"linux-arm64": "linux-arm64/path/to/executable",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Backend: &ManifestServer{
|
|
||||||
Executables: map[string]string{
|
|
||||||
"linux-amd64": "linux-amd64/path/to/executable",
|
|
||||||
"darwin-amd64": "darwin-amd64/path/to/executable",
|
|
||||||
"windows-amd64": "windows-amd64/path/to/executable",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"linux",
|
|
||||||
"amd64",
|
|
||||||
"linux-amd64/path/to/executable",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"deprecated backend field used, since no server present",
|
|
||||||
&Manifest{
|
|
||||||
Backend: &ManifestServer{
|
|
||||||
Executables: map[string]string{
|
|
||||||
"linux-amd64": "linux-amd64/path/to/executable",
|
|
||||||
"darwin-amd64": "darwin-amd64/path/to/executable",
|
|
||||||
"windows-amd64": "windows-amd64/path/to/executable",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"linux",
|
|
||||||
"amd64",
|
|
||||||
"linux-amd64/path/to/executable",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
@@ -798,28 +760,6 @@ func TestManifestHasServer(t *testing.T) {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"single executable defined via deprecated backend",
|
|
||||||
&Manifest{
|
|
||||||
Backend: &ManifestServer{
|
|
||||||
Executable: "path/to/executable",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"multiple executables defined via deprecated backend",
|
|
||||||
&Manifest{
|
|
||||||
Backend: &ManifestServer{
|
|
||||||
Executables: map[string]string{
|
|
||||||
"linux-amd64": "linux-amd64/path/to/executable",
|
|
||||||
"darwin-amd64": "darwin-amd64/path/to/executable",
|
|
||||||
"windows-amd64": "windows-amd64/path/to/executable",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func testPluginHealthCheckSuccess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, backend)
|
`, backend)
|
||||||
|
|
||||||
err = ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "backend": {"executable": "backend.exe"}}`), 0600)
|
err = ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "server": {"executable": "backend.exe"}}`), 0600)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
bundle := model.BundleInfoForPath(dir)
|
bundle := model.BundleInfoForPath(dir)
|
||||||
@@ -95,7 +95,7 @@ func testPluginHealthCheckPanic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, backend)
|
`, backend)
|
||||||
|
|
||||||
err = ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "backend": {"executable": "backend.exe"}}`), 0600)
|
err = ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "server": {"executable": "backend.exe"}}`), 0600)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
bundle := model.BundleInfoForPath(dir)
|
bundle := model.BundleInfoForPath(dir)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func testSupervisorInvalidExecutablePath(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "backend": {"executable": "/foo/../../backend.exe"}}`), 0600)
|
ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "server": {"executable": "/foo/../../backend.exe"}}`), 0600)
|
||||||
|
|
||||||
bundle := model.BundleInfoForPath(dir)
|
bundle := model.BundleInfoForPath(dir)
|
||||||
log := mlog.NewLogger(&mlog.LoggerConfiguration{
|
log := mlog.NewLogger(&mlog.LoggerConfiguration{
|
||||||
@@ -51,7 +51,7 @@ func testSupervisorNonExistentExecutablePath(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "backend": {"executable": "thisfileshouldnotexist"}}`), 0600)
|
ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "server": {"executable": "thisfileshouldnotexist"}}`), 0600)
|
||||||
|
|
||||||
bundle := model.BundleInfoForPath(dir)
|
bundle := model.BundleInfoForPath(dir)
|
||||||
log := mlog.NewLogger(&mlog.LoggerConfiguration{
|
log := mlog.NewLogger(&mlog.LoggerConfiguration{
|
||||||
@@ -81,7 +81,7 @@ func testSupervisorStartTimeout(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, backend)
|
`, backend)
|
||||||
|
|
||||||
ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "backend": {"executable": "backend.exe"}}`), 0600)
|
ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "server": {"executable": "backend.exe"}}`), 0600)
|
||||||
|
|
||||||
bundle := model.BundleInfoForPath(dir)
|
bundle := model.BundleInfoForPath(dir)
|
||||||
log := mlog.NewLogger(&mlog.LoggerConfiguration{
|
log := mlog.NewLogger(&mlog.LoggerConfiguration{
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user