diff --git a/pkg/cmd/grafana-cli/commands/commands.go b/pkg/cmd/grafana-cli/commands/commands.go index 4993d8aa045..f1b36c90ef2 100644 --- a/pkg/cmd/grafana-cli/commands/commands.go +++ b/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() diff --git a/pkg/cmd/grafana-cli/commands/install_command.go b/pkg/cmd/grafana-cli/commands/install_command.go index 4dfbfd80e31..9b9faaa3fe4 100644 --- a/pkg/cmd/grafana-cli/commands/install_command.go +++ b/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") } diff --git a/pkg/cmd/grafana-cli/main.go b/pkg/cmd/grafana-cli/main.go index 4e74578c604..b277714fe9b 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: "", + Value: "https://grafana-net.raintank.io/api/plugins", }, cli.BoolFlag{ Name: "debug, d", diff --git a/pkg/cmd/grafana-cli/services/services.go b/pkg/cmd/grafana-cli/services/services.go index fc77570b77c..cd03f755075 100644 --- a/pkg/cmd/grafana-cli/services/services.go +++ b/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) diff --git a/public/app/features/plugins/plugin_edit_ctrl.ts b/public/app/features/plugins/plugin_edit_ctrl.ts index 2d4362835d4..71beb9d0268 100644 --- a/public/app/features/plugins/plugin_edit_ctrl.ts +++ b/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 diff --git a/public/app/features/plugins/plugin_page_ctrl.ts b/public/app/features/plugins/plugin_page_ctrl.ts index 9157f14202e..6a840717a80 100644 --- a/public/app/features/plugins/plugin_page_ctrl.ts +++ b/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) {