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
81bb3e1e
Unverified
Commit
81bb3e1e
authored
Jan 18, 2018
by
Carl Bergquist
Committed by
GitHub
Jan 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10547 from grafana/provisioning
Dashboard provisioning. Replace folder property with path
parents
9e20004e
34d7f8a4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
11 deletions
+41
-11
pkg/services/provisioning/dashboards/config_reader_test.go
+2
-2
pkg/services/provisioning/dashboards/file_reader.go
+8
-2
pkg/services/provisioning/dashboards/file_reader_test.go
+29
-5
pkg/services/provisioning/dashboards/test-configs/dashboards-from-disk/dev-dashboards.yaml
+2
-2
No files found.
pkg/services/provisioning/dashboards/config_reader_test.go
View file @
81bb3e1e
...
...
@@ -33,7 +33,7 @@ func TestDashboardsAsConfig(t *testing.T) {
So
(
ds
.
Editable
,
ShouldBeTrue
)
So
(
len
(
ds
.
Options
),
ShouldEqual
,
1
)
So
(
ds
.
Options
[
"
folder
"
],
ShouldEqual
,
"/var/lib/grafana/dashboards"
)
So
(
ds
.
Options
[
"
path
"
],
ShouldEqual
,
"/var/lib/grafana/dashboards"
)
ds2
:=
cfg
[
1
]
...
...
@@ -44,7 +44,7 @@ func TestDashboardsAsConfig(t *testing.T) {
So
(
ds2
.
Editable
,
ShouldBeFalse
)
So
(
len
(
ds2
.
Options
),
ShouldEqual
,
1
)
So
(
ds2
.
Options
[
"
folder
"
],
ShouldEqual
,
"/var/lib/grafana/dashboards"
)
So
(
ds2
.
Options
[
"
path
"
],
ShouldEqual
,
"/var/lib/grafana/dashboards"
)
})
Convey
(
"Should skip broken config files"
,
func
()
{
...
...
pkg/services/provisioning/dashboards/file_reader.go
View file @
81bb3e1e
...
...
@@ -34,9 +34,15 @@ type fileReader struct {
}
func
NewDashboardFileReader
(
cfg
*
DashboardsAsConfig
,
log
log
.
Logger
)
(
*
fileReader
,
error
)
{
path
,
ok
:=
cfg
.
Options
[
"folder"
]
.
(
string
)
var
path
string
path
,
ok
:=
cfg
.
Options
[
"path"
]
.
(
string
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"Failed to load dashboards. folder param is not a string"
)
path
,
ok
=
cfg
.
Options
[
"folder"
]
.
(
string
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"Failed to load dashboards. path param is not a string"
)
}
log
.
Warn
(
"[Deprecated] The folder property is deprecated. Please use path instead."
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
os
.
IsNotExist
(
err
)
{
...
...
pkg/services/provisioning/dashboards/file_reader_test.go
View file @
81bb3e1e
...
...
@@ -42,7 +42,7 @@ func TestDashboardFileReader(t *testing.T) {
}
Convey
(
"Can read default dashboard"
,
func
()
{
cfg
.
Options
[
"
folder
"
]
=
defaultDashboards
cfg
.
Options
[
"
path
"
]
=
defaultDashboards
cfg
.
Folder
=
"Team A"
reader
,
err
:=
NewDashboardFileReader
(
cfg
,
logger
)
...
...
@@ -67,7 +67,7 @@ func TestDashboardFileReader(t *testing.T) {
})
Convey
(
"Should not update dashboards when db is newer"
,
func
()
{
cfg
.
Options
[
"
folder
"
]
=
oneDashboard
cfg
.
Options
[
"
path
"
]
=
oneDashboard
fakeRepo
.
getDashboard
=
append
(
fakeRepo
.
getDashboard
,
&
models
.
Dashboard
{
Updated
:
time
.
Now
()
.
Add
(
time
.
Hour
),
...
...
@@ -84,7 +84,7 @@ func TestDashboardFileReader(t *testing.T) {
})
Convey
(
"Can read default dashboard and replace old version in database"
,
func
()
{
cfg
.
Options
[
"
folder
"
]
=
oneDashboard
cfg
.
Options
[
"
path
"
]
=
oneDashboard
stat
,
_
:=
os
.
Stat
(
oneDashboard
+
"/dashboard1.json"
)
...
...
@@ -115,7 +115,7 @@ func TestDashboardFileReader(t *testing.T) {
})
Convey
(
"Broken dashboards should not cause error"
,
func
()
{
cfg
.
Options
[
"
folder
"
]
=
brokenDashboards
cfg
.
Options
[
"
path
"
]
=
brokenDashboards
_
,
err
:=
NewDashboardFileReader
(
cfg
,
logger
)
So
(
err
,
ShouldBeNil
)
...
...
@@ -167,7 +167,7 @@ func TestDashboardFileReader(t *testing.T) {
OrgId
:
1
,
Folder
:
""
,
Options
:
map
[
string
]
interface
{}{
"
folder
"
:
defaultDashboards
,
"
path
"
:
defaultDashboards
,
},
}
...
...
@@ -184,6 +184,30 @@ func TestDashboardFileReader(t *testing.T) {
So
(
shouldSkip
,
ShouldBeNil
)
})
})
Convey
(
"Can use bpth path and folder as dashboard path"
,
func
()
{
cfg
:=
&
DashboardsAsConfig
{
Name
:
"Default"
,
Type
:
"file"
,
OrgId
:
1
,
Folder
:
""
,
Options
:
map
[
string
]
interface
{}{},
}
Convey
(
"using path parameter"
,
func
()
{
cfg
.
Options
[
"path"
]
=
defaultDashboards
reader
,
err
:=
NewDashboardFileReader
(
cfg
,
log
.
New
(
"test-logger"
))
So
(
err
,
ShouldBeNil
)
So
(
reader
.
Path
,
ShouldEqual
,
defaultDashboards
)
})
Convey
(
"using folder as options"
,
func
()
{
cfg
.
Options
[
"folder"
]
=
defaultDashboards
reader
,
err
:=
NewDashboardFileReader
(
cfg
,
log
.
New
(
"test-logger"
))
So
(
err
,
ShouldBeNil
)
So
(
reader
.
Path
,
ShouldEqual
,
defaultDashboards
)
})
})
})
}
...
...
pkg/services/provisioning/dashboards/test-configs/dashboards-from-disk/dev-dashboards.yaml
View file @
81bb3e1e
...
...
@@ -4,9 +4,9 @@
editable
:
true
type
:
file
options
:
folder
:
/var/lib/grafana/dashboards
path
:
/var/lib/grafana/dashboards
-
name
:
'
default'
type
:
file
options
:
folder
:
/var/lib/grafana/dashboards
path
:
/var/lib/grafana/dashboards
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