浏览代码

Merge branch 'cli_upgradeFix'

bergquist 9 年之前
父节点
当前提交
c0384a04f8
共有 3 个文件被更改,包括 11 次插入4 次删除
  1. 1 0
      CHANGELOG.md
  2. 2 1
      pkg/cmd/grafana-cli/commands/commands.go
  3. 8 3
      pkg/cmd/grafana-cli/commands/install_command.go

+ 1 - 0
CHANGELOG.md

@@ -10,6 +10,7 @@
 * **Dashlist**: Fixed issue dashboard list panel and caching tags, fixes [#4768](https://github.com/grafana/grafana/issues/4768)
 * **Graph**: Fixed issue with unneeded scrollbar in legend for Firefox, fixes [#4760](https://github.com/grafana/grafana/issues/4760)
 * **Table panel**: Fixed issue table panel formating string array properties, fixes [#4791](https://github.com/grafana/grafana/issues/4791)
+* **grafana-cli**: Improve error message when failing to install plugins due to corrupt response, fixes [#4651](https://github.com/grafana/grafana/issues/4651)
 
 # 3.0.0-beta5 (2016-04-15)
 

+ 2 - 1
pkg/cmd/grafana-cli/commands/commands.go

@@ -4,6 +4,7 @@ import (
 	"os"
 
 	"github.com/codegangsta/cli"
+	"github.com/fatih/color"
 	"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
 )
 
@@ -12,7 +13,7 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C
 
 		cmd := &contextCommandLine{context}
 		if err := command(cmd); err != nil {
-			log.Error("\nError: ")
+			log.Errorf("\n%s: ", color.RedString("Error"))
 			log.Errorf("%s\n\n", err)
 
 			cmd.ShowHelp()

+ 8 - 3
pkg/cmd/grafana-cli/commands/install_command.go

@@ -127,10 +127,15 @@ func downloadFile(pluginName, filePath, url string) (err error) {
 		if r := recover(); r != nil {
 			retryCount++
 			if retryCount < 3 {
-				fmt.Printf("\nFailed downloading. Will retry once.\n%v\n", r)
-				downloadFile(pluginName, filePath, url)
+				fmt.Println("Failed downloading. Will retry once.")
+				err = downloadFile(pluginName, filePath, url)
 			} else {
-				panic(r)
+				failure := fmt.Sprintf("%v", r)
+				if failure == "runtime error: makeslice: len out of range" {
+					err = fmt.Errorf("Corrupt http response from source. Please try again.\n")
+				} else {
+					panic(r)
+				}
 			}
 		}
 	}()