Commit 68efedfa by Joan López de la Franca Beltran Committed by GitHub

App Plugins: Add backend support (#28272)

* Add backend support for app plugins

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
parent e1c44d7a
......@@ -2,12 +2,15 @@ package plugins
import (
"encoding/json"
"path/filepath"
"strings"
"github.com/gosimple/slug"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/grpcplugin"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util/errutil"
)
type AppPluginCss struct {
......@@ -21,6 +24,8 @@ type AppPlugin struct {
FoundChildPlugins []*PluginInclude `json:"-"`
Pinned bool `json:"-"`
Executable string `json:"executable,omitempty"`
}
// AppPluginRoute describes a plugin route that is defined in
......@@ -67,6 +72,15 @@ func (app *AppPlugin) Load(decoder *json.Decoder, base *PluginBase, backendPlugi
return err
}
if app.Backend {
cmd := ComposePluginStartCommand(app.Executable)
fullpath := filepath.Join(app.PluginDir, cmd)
factory := grpcplugin.NewBackendPlugin(app.Id, fullpath, grpcplugin.PluginStartFuncs{})
if err := backendPluginManager.Register(app.Id, factory); err != nil {
return errutil.Wrapf(err, "failed to register backend plugin")
}
}
Apps[app.Id] = app
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment