فهرست منبع

style(cli): fixed typos

bergquist 10 سال پیش
والد
کامیت
2fcb8b849e
2فایلهای تغییر یافته به همراه11 افزوده شده و 11 حذف شده
  1. 9 9
      pkg/cmd/grafana-cli/commands/install_command.go
  2. 2 2
      pkg/cmd/grafana-cli/commands/install_command_test.go

+ 9 - 9
pkg/cmd/grafana-cli/commands/install_command.go

@@ -26,8 +26,8 @@ func validateInput(c CommandLine, pluginFolder string) error {
 		return errors.New("missing path flag")
 	}
 
-	fileinfo, err := os.Stat(pluginDir)
-	if err != nil && !fileinfo.IsDir() {
+	fileInfo, err := os.Stat(pluginDir)
+	if err != nil && !fileInfo.IsDir() {
 		return errors.New("path is not a directory")
 	}
 
@@ -106,20 +106,20 @@ func SelectVersion(plugin m.Plugin, version string) (m.Version, error) {
 	return m.Version{}, errors.New("Could not find the version your looking for")
 }
 
-func RemoveGitBuildFromname(pluginname, filename string) string {
+func RemoveGitBuildFromName(pluginName, filename string) string {
 	r := regexp.MustCompile("^[a-zA-Z0-9_.-]*/")
-	return r.ReplaceAllString(filename, pluginname+"/")
+	return r.ReplaceAllString(filename, pluginName+"/")
 }
 
 var retryCount = 0
 
-func downloadFile(pluginName, filepath, url string) (err error) {
+func downloadFile(pluginName, filePath, url string) (err error) {
 	defer func() {
 		if r := recover(); r != nil {
 			retryCount++
 			if retryCount == 1 {
 				log.Debug("\nFailed downloading. Will retry once.\n")
-				downloadFile(pluginName, filepath, url)
+				downloadFile(pluginName, filePath, url)
 			} else {
 				panic(r)
 			}
@@ -142,12 +142,12 @@ func downloadFile(pluginName, filepath, url string) (err error) {
 		return err
 	}
 	for _, zf := range r.File {
-		newfile := path.Join(filepath, RemoveGitBuildFromname(pluginName, zf.Name))
+		newFile := path.Join(filePath, RemoveGitBuildFromName(pluginName, zf.Name))
 
 		if zf.FileInfo().IsDir() {
-			os.Mkdir(newfile, 0777)
+			os.Mkdir(newFile, 0777)
 		} else {
-			dst, err := os.Create(newfile)
+			dst, err := os.Create(newFile)
 			if err != nil {
 				log.Errorf("%v", err)
 			}

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

@@ -19,7 +19,7 @@ func TestFoldernameReplacement(t *testing.T) {
 
 		Convey("should be replaced with plugin name", func() {
 			for k, v := range paths {
-				So(RemoveGitBuildFromname(pluginName, k), ShouldEqual, v)
+				So(RemoveGitBuildFromName(pluginName, k), ShouldEqual, v)
 			}
 		})
 	})
@@ -32,7 +32,7 @@ func TestFoldernameReplacement(t *testing.T) {
 
 		Convey("should be replaced with plugin name", func() {
 			for k, v := range paths {
-				So(RemoveGitBuildFromname(pluginName, k), ShouldEqual, v)
+				So(RemoveGitBuildFromName(pluginName, k), ShouldEqual, v)
 			}
 		})
 	})