Plugins: Compose filesystem paths with filepath.Join (#28375)
* plugins: Fix filesystem path composition Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * plugins: Use filepath.Join to join filesystem paths Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ package plugins
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
@@ -45,7 +45,7 @@ func (p *DataSourcePlugin) Load(decoder *json.Decoder, base *PluginBase, backend
|
||||
|
||||
if p.Backend {
|
||||
cmd := ComposePluginStartCommand(p.Executable)
|
||||
fullpath := path.Join(p.PluginDir, cmd)
|
||||
fullpath := filepath.Join(p.PluginDir, cmd)
|
||||
factory := grpcplugin.NewBackendPlugin(p.Id, fullpath, grpcplugin.PluginStartFuncs{
|
||||
OnLegacyStart: p.onLegacyPluginStart,
|
||||
OnStart: p.onPluginStart,
|
||||
|
||||
@@ -54,8 +54,8 @@ func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) {
|
||||
|
||||
func (fp *FrontendPluginBase) handleModuleDefaults() {
|
||||
if isExternalPlugin(fp.PluginDir) {
|
||||
fp.Module = path.Join("plugins", fp.Id, "module")
|
||||
fp.BaseUrl = path.Join("public/plugins", fp.Id)
|
||||
fp.Module = filepath.Join("plugins", fp.Id, "module")
|
||||
fp.BaseUrl = filepath.Join("public/plugins", fp.Id)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ func (fp *FrontendPluginBase) handleModuleDefaults() {
|
||||
currentDir := filepath.Base(fp.PluginDir)
|
||||
// use path package for the following statements
|
||||
// because these are not file paths
|
||||
fp.Module = path.Join("app/plugins", fp.Type, currentDir, "module")
|
||||
fp.BaseUrl = path.Join("public/app/plugins", fp.Type, currentDir)
|
||||
fp.Module = filepath.Join("app/plugins", fp.Type, currentDir, "module")
|
||||
fp.BaseUrl = filepath.Join("public/app/plugins", fp.Type, currentDir)
|
||||
}
|
||||
|
||||
func isExternalPlugin(pluginDir string) bool {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
@@ -79,7 +78,7 @@ func (pm *PluginManager) Init() error {
|
||||
|
||||
pm.log.Info("Starting plugin search")
|
||||
|
||||
plugDir := path.Join(setting.StaticRootPath, "app/plugins")
|
||||
plugDir := filepath.Join(setting.StaticRootPath, "app/plugins")
|
||||
pm.log.Debug("Scanning core plugin directory", "dir", plugDir)
|
||||
if err := pm.scan(plugDir, false); err != nil {
|
||||
return errutil.Wrapf(err, "failed to scan core plugin directory '%s'", plugDir)
|
||||
|
||||
@@ -3,7 +3,7 @@ package plugins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
pluginModel "github.com/grafana/grafana-plugin-model/go/renderer"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -34,7 +34,7 @@ func (r *RendererPlugin) Load(decoder *json.Decoder, base *PluginBase, backendPl
|
||||
r.backendPluginManager = backendPluginManager
|
||||
|
||||
cmd := ComposePluginStartCommand("plugin_start")
|
||||
fullpath := path.Join(r.PluginDir, cmd)
|
||||
fullpath := filepath.Join(r.PluginDir, cmd)
|
||||
factory := grpcplugin.NewRendererPlugin(r.Id, fullpath, grpcplugin.PluginStartFuncs{
|
||||
OnLegacyStart: r.onLegacyPluginStart,
|
||||
OnStart: r.onPluginStart,
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
sdkgrpcplugin "github.com/grafana/grafana-plugin-sdk-go/backend/grpcplugin"
|
||||
@@ -38,7 +38,7 @@ func (p *TransformPlugin) Load(decoder *json.Decoder, base *PluginBase, backendP
|
||||
}
|
||||
|
||||
cmd := ComposePluginStartCommand(p.Executable)
|
||||
fullpath := path.Join(p.PluginDir, cmd)
|
||||
fullpath := filepath.Join(p.PluginDir, cmd)
|
||||
factory := grpcplugin.NewBackendPlugin(p.Id, fullpath, grpcplugin.PluginStartFuncs{
|
||||
OnStart: p.onPluginStart,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user