feat(cli): make repo url a parameter

this is a quick hack to support repo url as parameter. Will refactor
later
This commit is contained in:
bergquist
2016-03-07 13:27:51 +01:00
parent 3d2d8f2d86
commit f6c5242a93
6 changed files with 20 additions and 15 deletions

View File

@@ -11,8 +11,8 @@ import (
var IoHelper m.IoUtil = IoUtilImp{}
func ListAllPlugins() (m.PluginRepo, error) {
res, _ := goreq.Request{Uri: "https://raw.githubusercontent.com/grafana/grafana-plugin-repository/master/repo.json"}.Do()
func ListAllPlugins(repoUrl string) (m.PluginRepo, error) {
res, _ := goreq.Request{Uri: repoUrl}.Do()
var resp m.PluginRepo
err := res.Body.FromJsonTo(&resp)
@@ -59,16 +59,16 @@ func RemoveInstalledPlugin(pluginPath, id string) error {
return IoHelper.RemoveAll(path.Join(pluginPath, id))
}
func GetPlugin(id string) (m.Plugin, error) {
resp, err := ListAllPlugins()
func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) {
resp, err := ListAllPlugins(repoUrl)
if err != nil {
}
for _, i := range resp.Plugins {
if i.Id == id {
if i.Id == pluginId {
return i, nil
}
}
return m.Plugin{}, errors.New("could not find plugin named \"" + id + "\"")
return m.Plugin{}, errors.New("could not find plugin named \"" + pluginId + "\"")
}