From 7f8643efdec070d34d4fce40ab0ac31e6e0566d4 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 21 Mar 2016 10:01:07 +0100 Subject: [PATCH 1/4] feat(cli): make all plugin commands subcommands --- docs/sources/plugins/installation.md | 12 ++++++------ pkg/cmd/grafana-cli/commands/commands.go | 10 +++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/sources/plugins/installation.md b/docs/sources/plugins/installation.md index d3a8013ce2b..7a4ed1889f9 100644 --- a/docs/sources/plugins/installation.md +++ b/docs/sources/plugins/installation.md @@ -17,30 +17,30 @@ On Linux systems the grafana-cli will assume that the grafana plugin directory i List available plugins ``` -grafana-cli list-remote +grafana-cli plugins list-remote ``` Install a plugin type ``` -grafana-cli install +grafana-cli plugins install ``` List installed plugins ``` -grafana-cli ls +grafana-cli plugins ls ``` Upgrade all installed plugins ``` -grafana-cli upgrade-all +grafana-cli plugins upgrade-all ``` Upgrade one plugin ``` -grafana-cli upgrade +grafana-cli plugins upgrade ``` Remove one plugin ``` -grafana-cli remove +grafana-cli plugins remove ``` diff --git a/pkg/cmd/grafana-cli/commands/commands.go b/pkg/cmd/grafana-cli/commands/commands.go index f1b36c90ef2..55a0e2660ec 100644 --- a/pkg/cmd/grafana-cli/commands/commands.go +++ b/pkg/cmd/grafana-cli/commands/commands.go @@ -22,7 +22,7 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C } } -var Commands = []cli.Command{ +var pluginCommands = []cli.Command{ { Name: "install", Usage: "install ", @@ -49,3 +49,11 @@ var Commands = []cli.Command{ Action: runCommand(removeCommand), }, } + +var Commands = []cli.Command{ + { + Name: "plugins", + Usage: "Manage plugins for grafana", + Subcommands: pluginCommands, + }, +} From 14df3c62494a3d3c9e2eb28acd6199b7c14e596f Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 21 Mar 2016 10:05:23 +0100 Subject: [PATCH 2/4] feat(cli): use built in envvar support --- pkg/cmd/grafana-cli/main.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/grafana-cli/main.go b/pkg/cmd/grafana-cli/main.go index b277714fe9b..2b3b94f1751 100644 --- a/pkg/cmd/grafana-cli/main.go +++ b/pkg/cmd/grafana-cli/main.go @@ -12,10 +12,6 @@ import ( var version = "master" func getGrafanaPluginPath() string { - if os.Getenv("GF_PLUGIN_DIR") != "" { - return os.Getenv("GF_PLUGIN_DIR") - } - os := runtime.GOOS if os == "windows" { return "C:\\opt\\grafana\\plugins" @@ -34,14 +30,16 @@ func main() { app.Version = version app.Flags = []cli.Flag{ cli.StringFlag{ - Name: "path", - Usage: "path to the grafana installation", - Value: getGrafanaPluginPath(), + Name: "path", + Usage: "path to the grafana installation", + Value: getGrafanaPluginPath(), + EnvVar: "GF_PLUGIN_DIR", }, cli.StringFlag{ - Name: "repo", - Usage: "url to the plugin repository", - Value: "https://grafana-net.raintank.io/api/plugins", + Name: "repo", + Usage: "url to the plugin repository", + Value: "https://grafana-net.raintank.io/api/plugins", + EnvVar: "GF_PLUGIN_REPO", }, cli.BoolFlag{ Name: "debug, d", From 86a274a7eed37acb45f43c5e695e2bd6dce1b7d8 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 21 Mar 2016 12:30:13 +0100 Subject: [PATCH 3/4] feat(backendsrv): improves error response handling datasourceRequests that could not reach the destination threw invalid errors due to missing property. This fixes gives the user a better error message. closes #4428 --- public/app/core/services/backend_srv.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/app/core/services/backend_srv.js b/public/app/core/services/backend_srv.js index 6d0d112ba26..c5638af167e 100644 --- a/public/app/core/services/backend_srv.js +++ b/public/app/core/services/backend_srv.js @@ -105,6 +105,13 @@ function (angular, _, coreModule, config) { }); } + //populate error obj on Internal Error + if (_.isString(err.data) && err.status === 500 && !err.data) { + err.data = { + error: err.statusText + }; + } + // for Prometheus if (!err.data.message && _.isString(err.data.error)) { err.data.message = err.data.error; From 90c6b04361edf9f08adb3ed955f48dca767b94ae Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 21 Mar 2016 12:43:30 +0100 Subject: [PATCH 4/4] fix(backendsrv): remove invalid check --- public/app/core/services/backend_srv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/core/services/backend_srv.js b/public/app/core/services/backend_srv.js index c5638af167e..ff3784ab45e 100644 --- a/public/app/core/services/backend_srv.js +++ b/public/app/core/services/backend_srv.js @@ -106,7 +106,7 @@ function (angular, _, coreModule, config) { } //populate error obj on Internal Error - if (_.isString(err.data) && err.status === 500 && !err.data) { + if (_.isString(err.data) && err.status === 500) { err.data = { error: err.statusText };