File tree Expand file tree Collapse file tree 2 files changed +48
-30
lines changed Expand file tree Collapse file tree 2 files changed +48
-30
lines changed Original file line number Diff line number Diff line change @@ -8,39 +8,11 @@ import (
8
8
"github.com/codegangsta/cli"
9
9
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
10
10
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
11
+ "github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
11
12
)
12
13
13
14
var version = "master"
14
15
15
- func getGrafanaPluginDir () string {
16
- currentOS := runtime .GOOS
17
- defaultNix := "/var/lib/grafana/plugins"
18
-
19
- if currentOS == "windows" {
20
- return "../data/plugins"
21
- }
22
-
23
- pwd , err := os .Getwd ()
24
-
25
- if err != nil {
26
- logger .Error ("Could not get current path. using default" )
27
- return defaultNix
28
- }
29
-
30
- if isDevenvironment (pwd ) {
31
- return "../data/plugins"
32
- }
33
-
34
- return defaultNix
35
- }
36
-
37
- func isDevenvironment (pwd string ) bool {
38
- // if ../conf/defaults.ini exists, grafana is not installed as package
39
- // that its in development environment.
40
- _ , err := os .Stat ("../conf/defaults.ini" )
41
- return err == nil
42
- }
43
-
44
16
func main () {
45
17
setupLogging ()
46
18
@@ -54,7 +26,7 @@ func main() {
54
26
cli.StringFlag {
55
27
Name : "pluginsDir" ,
56
28
Usage : "path to the grafana plugin directory" ,
57
- Value : getGrafanaPluginDir ( ),
29
+ Value : utils . GetGrafanaPluginDir ( runtime . GOOS ),
58
30
EnvVar : "GF_PLUGIN_DIR" ,
59
31
},
60
32
cli.StringFlag {
Original file line number Diff line number Diff line change
1
+ package utils
2
+
3
+ import (
4
+ "os"
5
+
6
+ "github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
7
+ )
8
+
9
+ func GetGrafanaPluginDir (currentOS string ) string {
10
+ //currentOS := runtime.GOOS
11
+
12
+ if currentOS == "windows" {
13
+ return returnOsDefault (currentOS )
14
+ }
15
+
16
+ pwd , err := os .Getwd ()
17
+
18
+ if err != nil {
19
+ logger .Error ("Could not get current path. using default" )
20
+ return returnOsDefault (currentOS )
21
+ }
22
+
23
+ if isDevenvironment (pwd ) {
24
+ return "../data/plugins"
25
+ }
26
+
27
+ return returnOsDefault (currentOS )
28
+ }
29
+
30
+ func isDevenvironment (pwd string ) bool {
31
+ // if ../conf/defaults.ini exists, grafana is not installed as package
32
+ // that its in development environment.
33
+ _ , err := os .Stat ("../conf/defaults.ini" )
34
+ return err == nil
35
+ }
36
+
37
+ func returnOsDefault (currentOs string ) string {
38
+ switch currentOs {
39
+ case "windows" :
40
+ return "../data/plugins"
41
+ case "darwin" :
42
+ return "/usr/local/var/lib/grafana/plugins"
43
+ default : //"linux"
44
+ return "/var/lib/grafana/plugins"
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments