From c4a0ec844c242c8a890631b020d522dce59164fd Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Wed, 20 Jan 2016 06:13:45 +0800 Subject: [PATCH 1/2] get apiPlugins working again. --- pkg/plugins/api_plugin.go | 31 +++++++++++++++++++++++++++++++ pkg/plugins/models.go | 9 +++++++++ 2 files changed, 40 insertions(+) create mode 100644 pkg/plugins/api_plugin.go diff --git a/pkg/plugins/api_plugin.go b/pkg/plugins/api_plugin.go new file mode 100644 index 00000000000..b4296479ec1 --- /dev/null +++ b/pkg/plugins/api_plugin.go @@ -0,0 +1,31 @@ +package plugins + +import ( + "encoding/json" + "strings" + + "github.com/grafana/grafana/pkg/models" +) + +type ApiPluginRoute struct { + Path string `json:"path"` + Method string `json:"method"` + ReqSignedIn bool `json:"reqSignedIn"` + ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"` + ReqRole models.RoleType `json:"reqRole"` + Url string `json:"url"` +} + +type ApiPlugin struct { + PluginBase + Routes []*ApiPluginRoute `json:"routes"` +} + +func (app *ApiPlugin) Load(decoder *json.Decoder, pluginDir string) error { + if err := decoder.Decode(&app); err != nil { + return err + } + + ApiPlugins[app.Id] = app + return nil +} diff --git a/pkg/plugins/models.go b/pkg/plugins/models.go index 375bdf1a52c..69230cac629 100644 --- a/pkg/plugins/models.go +++ b/pkg/plugins/models.go @@ -73,3 +73,12 @@ func NewEnabledPlugins() EnabledPlugins { Apps: make([]*AppPlugin, 0), } } + +func (app *ApiPlugin) Load(decoder *json.Decoder, pluginDir string) error { + if err := decoder.Decode(&app); err != nil { + return err + } + + ApiPlugins[app.Id] = app + return nil +} From 92a085550e122e80470b3fb2ca5a631db77a0dc8 Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Wed, 20 Jan 2016 06:17:48 +0800 Subject: [PATCH 2/2] fix up imports --- pkg/plugins/api_plugin.go | 1 - pkg/plugins/models.go | 25 ------------------------- 2 files changed, 26 deletions(-) diff --git a/pkg/plugins/api_plugin.go b/pkg/plugins/api_plugin.go index b4296479ec1..0a47b7d18b2 100644 --- a/pkg/plugins/api_plugin.go +++ b/pkg/plugins/api_plugin.go @@ -2,7 +2,6 @@ package plugins import ( "encoding/json" - "strings" "github.com/grafana/grafana/pkg/models" ) diff --git a/pkg/plugins/models.go b/pkg/plugins/models.go index 69230cac629..b302181e840 100644 --- a/pkg/plugins/models.go +++ b/pkg/plugins/models.go @@ -2,8 +2,6 @@ package plugins import ( "encoding/json" - - "github.com/grafana/grafana/pkg/models" ) type PluginLoader interface { @@ -44,20 +42,6 @@ type PluginStaticRoute struct { PluginId string } -type ApiPluginRoute struct { - Path string `json:"path"` - Method string `json:"method"` - ReqSignedIn bool `json:"reqSignedIn"` - ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"` - ReqRole models.RoleType `json:"reqRole"` - Url string `json:"url"` -} - -type ApiPlugin struct { - PluginBase - Routes []*ApiPluginRoute `json:"routes"` -} - type EnabledPlugins struct { Panels []*PanelPlugin DataSources map[string]*DataSourcePlugin @@ -73,12 +57,3 @@ func NewEnabledPlugins() EnabledPlugins { Apps: make([]*AppPlugin, 0), } } - -func (app *ApiPlugin) Load(decoder *json.Decoder, pluginDir string) error { - if err := decoder.Decode(&app); err != nil { - return err - } - - ApiPlugins[app.Id] = app - return nil -}