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:
Torkel Ödegaard
2016-02-10 11:03:12 +01:00
parent 509b37eb91
commit 257b824d4f
8 changed files with 53 additions and 34 deletions

View File

@ -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"`