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
6b2d9181
Commit
6b2d9181
authored
Sep 20, 2018
by
Arno Uhlig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolve symlink on each run
parent
667ca3d5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
23 deletions
+28
-23
pkg/services/provisioning/dashboards/file_reader.go
+26
-22
pkg/services/provisioning/dashboards/file_reader_test.go
+2
-1
No files found.
pkg/services/provisioning/dashboards/file_reader.go
View file @
6b2d9181
...
@@ -43,26 +43,6 @@ func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReade
...
@@ -43,26 +43,6 @@ func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReade
log
.
Warn
(
"[Deprecated] The folder property is deprecated. Please use path instead."
)
log
.
Warn
(
"[Deprecated] The folder property is deprecated. Please use path instead."
)
}
}
if
_
,
err
:=
os
.
Stat
(
path
);
os
.
IsNotExist
(
err
)
{
log
.
Error
(
"Cannot read directory"
,
"error"
,
err
)
}
copy
:=
path
path
,
err
:=
filepath
.
Abs
(
path
)
if
err
!=
nil
{
log
.
Error
(
"Could not create absolute path "
,
"path"
,
path
)
}
path
,
err
=
filepath
.
EvalSymlinks
(
path
)
if
err
!=
nil
{
log
.
Error
(
"Failed to read content of symlinked path: %s"
,
path
)
}
if
path
==
""
{
path
=
copy
log
.
Info
(
"falling back to original path due to EvalSymlink/Abs failure"
)
}
return
&
fileReader
{
return
&
fileReader
{
Cfg
:
cfg
,
Cfg
:
cfg
,
Path
:
path
,
Path
:
path
,
...
@@ -99,7 +79,8 @@ func (fr *fileReader) ReadAndListen(ctx context.Context) error {
...
@@ -99,7 +79,8 @@ func (fr *fileReader) ReadAndListen(ctx context.Context) error {
}
}
func
(
fr
*
fileReader
)
startWalkingDisk
()
error
{
func
(
fr
*
fileReader
)
startWalkingDisk
()
error
{
if
_
,
err
:=
os
.
Stat
(
fr
.
Path
);
err
!=
nil
{
resolvedPath
:=
fr
.
resolvePath
(
fr
.
Path
)
if
_
,
err
:=
os
.
Stat
(
resolvedPath
);
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
return
err
return
err
}
}
...
@@ -116,7 +97,7 @@ func (fr *fileReader) startWalkingDisk() error {
...
@@ -116,7 +97,7 @@ func (fr *fileReader) startWalkingDisk() error {
}
}
filesFoundOnDisk
:=
map
[
string
]
os
.
FileInfo
{}
filesFoundOnDisk
:=
map
[
string
]
os
.
FileInfo
{}
err
=
filepath
.
Walk
(
fr
.
Path
,
createWalkFn
(
filesFoundOnDisk
))
err
=
filepath
.
Walk
(
resolved
Path
,
createWalkFn
(
filesFoundOnDisk
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -344,6 +325,29 @@ func (fr *fileReader) readDashboardFromFile(path string, lastModified time.Time,
...
@@ -344,6 +325,29 @@ func (fr *fileReader) readDashboardFromFile(path string, lastModified time.Time,
},
nil
},
nil
}
}
func
(
fr
*
fileReader
)
resolvePath
(
path
string
)
string
{
if
_
,
err
:=
os
.
Stat
(
path
);
os
.
IsNotExist
(
err
)
{
fr
.
log
.
Error
(
"Cannot read directory"
,
"error"
,
err
)
}
copy
:=
path
path
,
err
:=
filepath
.
Abs
(
path
)
if
err
!=
nil
{
fr
.
log
.
Error
(
"Could not create absolute path "
,
"path"
,
path
)
}
path
,
err
=
filepath
.
EvalSymlinks
(
path
)
if
err
!=
nil
{
fr
.
log
.
Error
(
"Failed to read content of symlinked path: %s"
,
path
)
}
if
path
==
""
{
path
=
copy
fr
.
log
.
Info
(
"falling back to original path due to EvalSymlink/Abs failure"
)
}
return
path
}
type
provisioningMetadata
struct
{
type
provisioningMetadata
struct
{
uid
string
uid
string
title
string
title
string
...
...
pkg/services/provisioning/dashboards/file_reader_test.go
View file @
6b2d9181
...
@@ -67,7 +67,8 @@ func TestCreatingNewDashboardFileReader(t *testing.T) {
...
@@ -67,7 +67,8 @@ func TestCreatingNewDashboardFileReader(t *testing.T) {
reader
,
err
:=
NewDashboardFileReader
(
cfg
,
log
.
New
(
"test-logger"
))
reader
,
err
:=
NewDashboardFileReader
(
cfg
,
log
.
New
(
"test-logger"
))
So
(
err
,
ShouldBeNil
)
So
(
err
,
ShouldBeNil
)
So
(
filepath
.
IsAbs
(
reader
.
Path
),
ShouldBeTrue
)
resolvedPath
:=
reader
.
resolvePath
(
reader
.
Path
)
So
(
filepath
.
IsAbs
(
resolvedPath
),
ShouldBeTrue
)
})
})
})
})
}
}
...
...
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