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
5a766240
Commit
5a766240
authored
Feb 09, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioning: createWalkFn doesnt have to be attached to the filereader anymore
parent
e93fe9db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
18 deletions
+3
-18
pkg/services/provisioning/dashboards/file_reader.go
+1
-3
pkg/services/provisioning/dashboards/file_reader_test.go
+2
-15
No files found.
pkg/services/provisioning/dashboards/file_reader.go
View file @
5a766240
...
...
@@ -29,7 +29,6 @@ type fileReader struct {
Path
string
log
log
.
Logger
dashboardRepo
dashboards
.
Repository
createWalk
func
(
filesOnDisk
map
[
string
]
os
.
FileInfo
)
filepath
.
WalkFunc
}
func
NewDashboardFileReader
(
cfg
*
DashboardsAsConfig
,
log
log
.
Logger
)
(
*
fileReader
,
error
)
{
...
...
@@ -53,7 +52,6 @@ func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReade
Path
:
path
,
log
:
log
,
dashboardRepo
:
dashboards
.
GetRepository
(),
createWalk
:
createWalkFn
,
},
nil
}
...
...
@@ -102,7 +100,7 @@ func (fr *fileReader) startWalkingDisk() error {
}
filesFoundOnDisk
:=
map
[
string
]
os
.
FileInfo
{}
err
=
filepath
.
Walk
(
fr
.
Path
,
fr
.
createWalk
(
filesFoundOnDisk
))
err
=
filepath
.
Walk
(
fr
.
Path
,
createWalkFn
(
filesFoundOnDisk
))
if
err
!=
nil
{
return
err
}
...
...
pkg/services/provisioning/dashboards/file_reader_test.go
View file @
5a766240
...
...
@@ -144,28 +144,15 @@ func TestDashboardFileReader(t *testing.T) {
})
Convey
(
"Walking the folder with dashboards"
,
func
()
{
cfg
:=
&
DashboardsAsConfig
{
Name
:
"Default"
,
Type
:
"file"
,
OrgId
:
1
,
Folder
:
""
,
Options
:
map
[
string
]
interface
{}{
"path"
:
defaultDashboards
,
},
}
reader
,
err
:=
NewDashboardFileReader
(
cfg
,
log
.
New
(
"test-logger"
))
So
(
err
,
ShouldBeNil
)
noFiles
:=
map
[
string
]
os
.
FileInfo
{}
Convey
(
"should skip dirs that starts with ."
,
func
()
{
shouldSkip
:=
reader
.
createWalk
(
noFiles
)(
"path"
,
&
FakeFileInfo
{
isDirectory
:
true
,
name
:
".folder"
},
nil
)
shouldSkip
:=
createWalkFn
(
noFiles
)(
"path"
,
&
FakeFileInfo
{
isDirectory
:
true
,
name
:
".folder"
},
nil
)
So
(
shouldSkip
,
ShouldEqual
,
filepath
.
SkipDir
)
})
Convey
(
"should keep walking if file is not .json"
,
func
()
{
shouldSkip
:=
reader
.
createWalk
(
noFiles
)(
"path"
,
&
FakeFileInfo
{
isDirectory
:
true
,
name
:
"folder"
},
nil
)
shouldSkip
:=
createWalkFn
(
noFiles
)(
"path"
,
&
FakeFileInfo
{
isDirectory
:
true
,
name
:
"folder"
},
nil
)
So
(
shouldSkip
,
ShouldBeNil
)
})
})
...
...
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