Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7a913f77
Commit
7a913f77
authored
Aug 15, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(cli): add default plugin folder for MAC OS
closes #5806
parent
0ea3458f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
30 deletions
+48
-30
pkg/cmd/grafana-cli/main.go
+2
-30
pkg/cmd/grafana-cli/utils/grafana_path.go
+46
-0
No files found.
pkg/cmd/grafana-cli/main.go
View file @
7a913f77
...
@@ -8,39 +8,11 @@ import (
...
@@ -8,39 +8,11 @@ import (
"github.com/codegangsta/cli"
"github.com/codegangsta/cli"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
)
)
var
version
=
"master"
var
version
=
"master"
func
getGrafanaPluginDir
()
string
{
currentOS
:=
runtime
.
GOOS
defaultNix
:=
"/var/lib/grafana/plugins"
if
currentOS
==
"windows"
{
return
"../data/plugins"
}
pwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
logger
.
Error
(
"Could not get current path. using default"
)
return
defaultNix
}
if
isDevenvironment
(
pwd
)
{
return
"../data/plugins"
}
return
defaultNix
}
func
isDevenvironment
(
pwd
string
)
bool
{
// if ../conf/defaults.ini exists, grafana is not installed as package
// that its in development environment.
_
,
err
:=
os
.
Stat
(
"../conf/defaults.ini"
)
return
err
==
nil
}
func
main
()
{
func
main
()
{
setupLogging
()
setupLogging
()
...
@@ -54,7 +26,7 @@ func main() {
...
@@ -54,7 +26,7 @@ func main() {
cli
.
StringFlag
{
cli
.
StringFlag
{
Name
:
"pluginsDir"
,
Name
:
"pluginsDir"
,
Usage
:
"path to the grafana plugin directory"
,
Usage
:
"path to the grafana plugin directory"
,
Value
:
getGrafanaPluginDir
(
),
Value
:
utils
.
GetGrafanaPluginDir
(
runtime
.
GOOS
),
EnvVar
:
"GF_PLUGIN_DIR"
,
EnvVar
:
"GF_PLUGIN_DIR"
,
},
},
cli
.
StringFlag
{
cli
.
StringFlag
{
...
...
pkg/cmd/grafana-cli/utils/grafana_path.go
0 → 100644
View file @
7a913f77
package
utils
import
(
"os"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
)
func
GetGrafanaPluginDir
(
currentOS
string
)
string
{
//currentOS := runtime.GOOS
if
currentOS
==
"windows"
{
return
returnOsDefault
(
currentOS
)
}
pwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
logger
.
Error
(
"Could not get current path. using default"
)
return
returnOsDefault
(
currentOS
)
}
if
isDevenvironment
(
pwd
)
{
return
"../data/plugins"
}
return
returnOsDefault
(
currentOS
)
}
func
isDevenvironment
(
pwd
string
)
bool
{
// if ../conf/defaults.ini exists, grafana is not installed as package
// that its in development environment.
_
,
err
:=
os
.
Stat
(
"../conf/defaults.ini"
)
return
err
==
nil
}
func
returnOsDefault
(
currentOs
string
)
string
{
switch
currentOs
{
case
"windows"
:
return
"../data/plugins"
case
"darwin"
:
return
"/usr/local/var/lib/grafana/plugins"
default
:
//"linux"
return
"/var/lib/grafana/plugins"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment