mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 05:37:53 +08:00
feat(plugins): better logging and handling of loading plugins, try to create plugins dir if it does not exist, fixes #3974
This commit is contained in:
@ -2,6 +2,11 @@ package plugins
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type PluginLoader interface {
|
||||
@ -18,6 +23,20 @@ type PluginBase struct {
|
||||
PluginDir string `json:"-"`
|
||||
}
|
||||
|
||||
func (pb *PluginBase) registerPlugin(pluginDir string) error {
|
||||
if _, exists := Plugins[pb.Id]; exists {
|
||||
return errors.New("Plugin with same id already exists")
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(pluginDir, setting.StaticRootPath) {
|
||||
log.Info("Plugins: Registering plugin %v", pb.Name)
|
||||
}
|
||||
|
||||
pb.PluginDir = pluginDir
|
||||
Plugins[pb.Id] = pb
|
||||
return nil
|
||||
}
|
||||
|
||||
type PluginInfo struct {
|
||||
Author PluginInfoLink `json:"author"`
|
||||
Description string `json:"description"`
|
||||
|
Reference in New Issue
Block a user