diff --git a/pkg/cmd/grafana-cli/commands/install_command.go b/pkg/cmd/grafana-cli/commands/install_command.go index c58ed12668f..49e7d781389 100644 --- a/pkg/cmd/grafana-cli/commands/install_command.go +++ b/pkg/cmd/grafana-cli/commands/install_command.go @@ -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 diff --git a/pkg/cmd/grafana-cli/commands/ls_command.go b/pkg/cmd/grafana-cli/commands/ls_command.go index 5a90df89d8a..05dd57bfd2a 100644 --- a/pkg/cmd/grafana-cli/commands/ls_command.go +++ b/pkg/cmd/grafana-cli/commands/ls_command.go @@ -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 } diff --git a/pkg/cmd/grafana-cli/commands/ls_command_test.go b/pkg/cmd/grafana-cli/commands/ls_command_test.go index fa49375234d..650c6270bf0 100644 --- a/pkg/cmd/grafana-cli/commands/ls_command_test.go +++ b/pkg/cmd/grafana-cli/commands/ls_command_test.go @@ -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") } diff --git a/pkg/cmd/grafana-cli/main.go b/pkg/cmd/grafana-cli/main.go index 12bebd46898..4e74578c604 100644 --- a/pkg/cmd/grafana-cli/main.go +++ b/pkg/cmd/grafana-cli/main.go @@ -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", diff --git a/pkg/cmd/grafana-cli/services/services.go b/pkg/cmd/grafana-cli/services/services.go index 1ffc60abf4c..fc77570b77c 100644 --- a/pkg/cmd/grafana-cli/services/services.go +++ b/pkg/cmd/grafana-cli/services/services.go @@ -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)