Commit 18c5e900 by bergquist

Merge branch 'cli_compose_download_url'

parents 43073da7 fee0745e
......@@ -4,6 +4,7 @@ import (
"archive/zip"
"bytes"
"errors"
"fmt"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
......@@ -64,30 +65,31 @@ func InstallPlugin(pluginName, version string, c CommandLine) error {
return err
}
url := v.Url
commit := v.Commit
if version == "" {
version = v.Version
}
downloadURL := url + "/archive/" + commit + ".zip"
downloadURL := fmt.Sprintf("%s/%s/versions/%s/download",
c.GlobalString("repo"),
pluginName,
version)
log.Infof("installing %v @ %v\n", plugin.Id, version)
log.Infof("from url: %v\n", downloadURL)
log.Infof("on commit: %v\n", commit)
log.Infof("into: %v\n", pluginFolder)
err = downloadFile(plugin.Id, pluginFolder, downloadURL)
if err == nil {
log.Infof("Installed %v successfully ✔\n", plugin.Id)
if err != nil {
return err
}
log.Infof("Installed %v successfully ✔\n", plugin.Id)
res, _ := s.ReadPlugin(pluginFolder, pluginName)
for _, v := range res.Dependency.Plugins {
InstallPlugin(v.Id, version, c)
log.Infof("Installed Dependency: %v ✔\n", v.Id)
log.Infof("Installed dependency: %v ✔\n", v.Id)
}
return err
......
......@@ -10,7 +10,7 @@ import (
var ls_getPlugins func(path string) []m.InstalledPlugin = s.GetLocalPlugins
var validateLsCommmand = func(pluginDir string) error {
var validateLsCommand = func(pluginDir string) error {
if pluginDir == "" {
return errors.New("missing path flag")
}
......@@ -31,7 +31,7 @@ var validateLsCommmand = func(pluginDir string) error {
func lsCommand(c CommandLine) error {
pluginDir := c.GlobalString("path")
if err := validateLsCommmand(pluginDir); err != nil {
if err := validateLsCommand(pluginDir); err != nil {
return err
}
......
......@@ -9,10 +9,10 @@ import (
)
func TestMissingPath(t *testing.T) {
var org = validateLsCommmand
var org = validateLsCommand
Convey("ls command", t, func() {
validateLsCommmand = org
validateLsCommand = org
Convey("Missing path", func() {
commandLine := &commandstest.FakeCommandLine{
......@@ -61,7 +61,7 @@ func TestMissingPath(t *testing.T) {
},
}
validateLsCommmand = func(pluginDir string) error {
validateLsCommand = func(pluginDir string) error {
return errors.New("dummie error")
}
......
......@@ -41,7 +41,7 @@ func main() {
cli.StringFlag{
Name: "repo",
Usage: "url to the plugin repository",
Value: "https://raw.githubusercontent.com/grafana/grafana-plugin-repository/master/repo.json",
Value: "",
},
cli.BoolFlag{
Name: "debug, d",
......
......@@ -12,7 +12,8 @@ import (
var IoHelper m.IoUtil = IoUtilImp{}
func ListAllPlugins(repoUrl string) (m.PluginRepo, error) {
res, _ := goreq.Request{Uri: repoUrl, MaxRedirects: 3}.Do()
res, _ := goreq.Request{Uri: repoUrl + "/repo", MaxRedirects: 3}.Do()
var resp m.PluginRepo
err := res.Body.FromJsonTo(&resp)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment