Sfoglia il codice sorgente

Merge branch 'master' of github.com:grafana/grafana

Torkel Ödegaard 9 anni fa
parent
commit
ef7d8ab90b

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

@@ -11,6 +11,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("%s\n\n", err)
 
 			cmd.ShowHelp()

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

@@ -28,7 +28,15 @@ func validateInput(c CommandLine, pluginFolder string) error {
 	}
 
 	fileInfo, err := os.Stat(pluginDir)
-	if err != nil && !fileInfo.IsDir() {
+	if err != nil {
+		if err = os.MkdirAll(pluginDir, os.ModePerm); err != nil {
+			return errors.New("path is not a directory")
+		}
+
+		return nil
+	}
+
+	if !fileInfo.IsDir() {
 		return errors.New("path is not a directory")
 	}
 

+ 1 - 1
pkg/cmd/grafana-cli/main.go

@@ -41,7 +41,7 @@ func main() {
 		cli.StringFlag{
 			Name:  "repo",
 			Usage: "url to the plugin repository",
-			Value: "",
+			Value: "https://grafana-net.raintank.io/api/plugins",
 		},
 		cli.BoolFlag{
 			Name:  "debug, d",

+ 6 - 1
pkg/cmd/grafana-cli/services/services.go

@@ -3,6 +3,7 @@ package services
 import (
 	"encoding/json"
 	"errors"
+	"fmt"
 	"github.com/franela/goreq"
 	"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
 	m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
@@ -12,8 +13,12 @@ import (
 var IoHelper m.IoUtil = IoUtilImp{}
 
 func ListAllPlugins(repoUrl string) (m.PluginRepo, error) {
+	fullUrl := repoUrl + "/repo"
+	res, _ := goreq.Request{Uri: fullUrl, MaxRedirects: 3}.Do()
 
-	res, _ := goreq.Request{Uri: repoUrl + "/repo", MaxRedirects: 3}.Do()
+	if res.StatusCode != 200 {
+		return m.PluginRepo{}, fmt.Errorf("Could not access %s statuscode %v", fullUrl, res.StatusCode)
+	}
 
 	var resp m.PluginRepo
 	err := res.Body.FromJsonTo(&resp)

+ 1 - 1
public/app/features/plugins/plugin_edit_ctrl.ts

@@ -78,7 +78,7 @@ export class PluginEditCtrl {
         secureJsonData: self.model.secureJsonData,
       }, {});
 
-      return self.backendSrv.post(`/api/org/plugins/${self.pluginId}/settings`, updateCmd);
+      return self.backendSrv.post(`/api/plugins/${self.pluginId}/settings`, updateCmd);
     });
 
     // if set, performt he postUpdate hook. If a promise is returned it will block

+ 1 - 1
public/app/features/plugins/plugin_page_ctrl.ts

@@ -11,7 +11,7 @@ export class AppPageCtrl {
   /** @ngInject */
   constructor(private backendSrv, private $routeParams: any, private $rootScope) {
     this.pluginId = $routeParams.pluginId;
-    this.backendSrv.get(`/api/org/plugins/${this.pluginId}/settings`).then(app => {
+    this.backendSrv.get(`/api/plugins/${this.pluginId}/settings`).then(app => {
       this.appModel = app;
       this.page = _.findWhere(app.pages, {slug: this.$routeParams.slug});
       if (!this.page) {