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
34d7f8a4
Commit
34d7f8a4
authored
Jan 17, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboards as cfg: property path replaces folder
parent
18350796
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
pkg/services/provisioning/dashboards/file_reader.go
+8
-2
pkg/services/provisioning/dashboards/file_reader_test.go
+29
-5
No files found.
pkg/services/provisioning/dashboards/file_reader.go
View file @
34d7f8a4
...
...
@@ -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 @
34d7f8a4
...
...
@@ -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
)
})
})
})
}
...
...
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