Skip to content

Commit af1c8dc

Browse files
committed
feat(cli): adds support for dist/plugin.json location for plugins
ref grafana#5410
1 parent 2123fbd commit af1c8dc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pkg/cmd/grafana-cli/services/services.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,23 @@ func ListAllPlugins(repoUrl string) (m.PluginRepo, error) {
3333
}
3434

3535
func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) {
36-
pluginDataPath := path.Join(pluginDir, pluginName, "plugin.json")
37-
pluginData, _ := IoHelper.ReadFile(pluginDataPath)
36+
distPluginDataPath := path.Join(pluginDir, pluginName, "dist", "plugin.json")
37+
38+
var data []byte
39+
var err error
40+
data, err = IoHelper.ReadFile(distPluginDataPath)
41+
42+
if err != nil {
43+
pluginDataPath := path.Join(pluginDir, pluginName, "plugin.json")
44+
data, err = IoHelper.ReadFile(pluginDataPath)
45+
46+
if err != nil {
47+
return m.InstalledPlugin{}, errors.New("Could not find dist/plugin.json or plugin.json on " + pluginName + " in " + pluginDir)
48+
}
49+
}
3850

3951
res := m.InstalledPlugin{}
40-
json.Unmarshal(pluginData, &res)
52+
json.Unmarshal(data, &res)
4153

4254
if res.Info.Version == "" {
4355
res.Info.Version = "0.0.0"

0 commit comments

Comments
 (0)