From 75dcaecc998401c3f7c1857049a9de9bc2801c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Mon, 23 Sep 2019 22:54:28 -0700 Subject: [PATCH] Plugins: Skips existence of module.js for renderer plugins (#19318) * Fix: Skips test for module.js for plugins of renderer type Fixes #19130 * Refactor: Changes after PR comments * Chore: Fixes go lint issue --- pkg/plugins/plugins.go | 6 +++++- pkg/plugins/plugins_test.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go index d07ddaa63fa..dcef2f0f76e 100644 --- a/pkg/plugins/plugins.go +++ b/pkg/plugins/plugins.go @@ -217,7 +217,7 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error { loader = reflect.New(reflect.TypeOf(pluginGoType)).Interface().(PluginLoader) // External plugins need a module.js file for SystemJS to load - if !strings.HasPrefix(pluginJsonFilePath, setting.StaticRootPath) { + if !strings.HasPrefix(pluginJsonFilePath, setting.StaticRootPath) && !scanner.IsBackendOnlyPlugin(pluginCommon.Type) { module := filepath.Join(filepath.Dir(pluginJsonFilePath), "module.js") if _, err := os.Stat(module); os.IsNotExist(err) { plog.Warn("Plugin missing module.js", @@ -231,6 +231,10 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error { return loader.Load(jsonParser, currentDir) } +func (scanner *PluginScanner) IsBackendOnlyPlugin(pluginType string) bool { + return pluginType == "renderer" +} + func GetPluginMarkdown(pluginId string, name string) ([]byte, error) { plug, exists := Plugins[pluginId] if !exists { diff --git a/pkg/plugins/plugins_test.go b/pkg/plugins/plugins_test.go index d16e6abb4c7..b5d7a752fe5 100644 --- a/pkg/plugins/plugins_test.go +++ b/pkg/plugins/plugins_test.go @@ -42,4 +42,18 @@ func TestPluginScans(t *testing.T) { So(Apps["test-app"].Info.Screenshots[1].Path, ShouldEqual, "public/plugins/test-app/img/screenshot2.png") }) + Convey("When checking if renderer is backend only plugin", t, func() { + pluginScanner := &PluginScanner{} + result := pluginScanner.IsBackendOnlyPlugin("renderer") + + So(result, ShouldEqual, true) + }) + + Convey("When checking if app is backend only plugin", t, func() { + pluginScanner := &PluginScanner{} + result := pluginScanner.IsBackendOnlyPlugin("app") + + So(result, ShouldEqual, false) + }) + }