Skip to content

Commit 583c0f0

Browse files
committed
feat(cli): adds better support for plugin folder in dev
1 parent 469c43c commit 583c0f0

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

pkg/cmd/grafana-cli/main.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,37 @@ import (
88
"github.com/codegangsta/cli"
99
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
1010
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
11+
"strings"
1112
)
1213

1314
var version = "master"
1415

1516
func getGrafanaPluginDir() string {
16-
os := runtime.GOOS
17-
if os == "windows" {
17+
currentOS := runtime.GOOS
18+
defaultNix := "/var/lib/grafana/plugins"
19+
20+
if currentOS == "windows" {
1821
return "C:\\opt\\grafana\\plugins"
19-
} else {
20-
return "/var/lib/grafana/plugins"
2122
}
23+
24+
pwd, err := os.Getwd()
25+
26+
if err != nil {
27+
log.Error("Could not get current path. using default")
28+
return defaultNix
29+
}
30+
31+
if isDevenvironment(pwd) {
32+
return "../../../data/plugins"
33+
}
34+
35+
return defaultNix
36+
}
37+
38+
func isDevenvironment(pwd string) bool {
39+
// if grafana-cli is executed from the cmd folder we can assume
40+
// that its in development environment.
41+
return strings.HasSuffix(pwd, "/pkg/cmd/grafana-cli")
2242
}
2343

2444
func main() {

0 commit comments

Comments
 (0)