|
|
|
@ -44,7 +44,7 @@ func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if res.Id == "" { |
|
|
|
|
return m.InstalledPlugin{}, errors.New("could not read find plugin " + pluginName) |
|
|
|
|
return m.InstalledPlugin{}, errors.New("could not find plugin " + pluginName + " in " + pluginDir) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return res, nil |
|
|
|
@ -69,13 +69,21 @@ func RemoveInstalledPlugin(pluginPath, id string) error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) { |
|
|
|
|
resp, _ := ListAllPlugins(repoUrl) |
|
|
|
|
fullUrl := repoUrl + "/repo/" + pluginId |
|
|
|
|
|
|
|
|
|
for _, i := range resp.Plugins { |
|
|
|
|
if i.Id == pluginId { |
|
|
|
|
return i, nil |
|
|
|
|
res, err := goreq.Request{Uri: fullUrl, MaxRedirects: 3}.Do() |
|
|
|
|
if err != nil { |
|
|
|
|
return m.Plugin{}, err |
|
|
|
|
} |
|
|
|
|
if res.StatusCode != 200 { |
|
|
|
|
return m.Plugin{}, fmt.Errorf("Could not access %s statuscode %v", fullUrl, res.StatusCode) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var resp m.Plugin |
|
|
|
|
err = res.Body.FromJsonTo(&resp) |
|
|
|
|
if err != nil { |
|
|
|
|
return m.Plugin{}, errors.New("Could not load plugin data") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return m.Plugin{}, errors.New("could not find plugin named \"" + pluginId + "\"") |
|
|
|
|
return resp, nil |
|
|
|
|
} |
|
|
|
|