provisioning: follow symlinked folders

fixes #11958
This commit is contained in:
bergquist 2018-05-21 09:03:32 +02:00
parent d5aeae3a90
commit 47d3884377
3 changed files with 45 additions and 0 deletions

View File

@ -47,6 +47,11 @@ func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReade
log.Error("Cannot read directory", "error", err)
}
path, err := filepath.EvalSymlinks(path)
if err != nil {
log.Error("Failed to read content of symlinked path: %s", path)
}
absPath, err := filepath.Abs(path)
if err != nil {
log.Error("Could not create absolute path ", "path", path)

View File

@ -0,0 +1,39 @@
// +build linux
package dashboards
import (
"path/filepath"
"testing"
"github.com/grafana/grafana/pkg/log"
)
var (
symlinkedFolder = "testdata/test-dashboards/symlink"
)
func TestProvsionedSymlinkedFolder(t *testing.T) {
cfg := &DashboardsAsConfig{
Name: "Default",
Type: "file",
OrgId: 1,
Folder: "",
Options: map[string]interface{}{"path": symlinkedFolder},
}
reader, err := NewDashboardFileReader(cfg, log.New("test-logger"))
if err != nil {
t.Error("expected err to be nil")
}
want, err := filepath.Abs(containingId)
if err != nil {
t.Errorf("expected err to be nill")
}
if reader.Path != want {
t.Errorf("got %s want %s", reader.Path, want)
}
}

View File

@ -0,0 +1 @@
containing-id/