From af1c8dc5d9b2f4bddae38c231f00801a54157887 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 23 Jun 2016 08:35:40 +0200 Subject: [PATCH] feat(cli): adds support for dist/plugin.json location for plugins ref #5410 --- pkg/cmd/grafana-cli/services/services.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/grafana-cli/services/services.go b/pkg/cmd/grafana-cli/services/services.go index c5991a6c7bc..1c53619c071 100644 --- a/pkg/cmd/grafana-cli/services/services.go +++ b/pkg/cmd/grafana-cli/services/services.go @@ -33,11 +33,23 @@ func ListAllPlugins(repoUrl string) (m.PluginRepo, error) { } func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) { - pluginDataPath := path.Join(pluginDir, pluginName, "plugin.json") - pluginData, _ := IoHelper.ReadFile(pluginDataPath) + distPluginDataPath := path.Join(pluginDir, pluginName, "dist", "plugin.json") + + var data []byte + var err error + data, err = IoHelper.ReadFile(distPluginDataPath) + + if err != nil { + pluginDataPath := path.Join(pluginDir, pluginName, "plugin.json") + data, err = IoHelper.ReadFile(pluginDataPath) + + if err != nil { + return m.InstalledPlugin{}, errors.New("Could not find dist/plugin.json or plugin.json on " + pluginName + " in " + pluginDir) + } + } res := m.InstalledPlugin{} - json.Unmarshal(pluginData, &res) + json.Unmarshal(data, &res) if res.Info.Version == "" { res.Info.Version = "0.0.0"