Commit b28ea0b4 by bergquist

dashboards as cfg: type

parent 2a18345e
...@@ -33,7 +33,7 @@ func (provider *DashboardProvisioner) Provision(ctx context.Context) error { ...@@ -33,7 +33,7 @@ func (provider *DashboardProvisioner) Provision(ctx context.Context) error {
for _, cfg := range cfgs { for _, cfg := range cfgs {
switch cfg.Type { switch cfg.Type {
case "file": case "file":
fileReader, err := NewDashboardFilereader(cfg, provider.log.New("type", cfg.Type, "name", cfg.Name)) fileReader, err := NewDashboardFileReader(cfg, provider.log.New("type", cfg.Type, "name", cfg.Name))
if err != nil { if err != nil {
return err return err
} }
......
...@@ -26,7 +26,7 @@ type fileReader struct { ...@@ -26,7 +26,7 @@ type fileReader struct {
cache *gocache.Cache cache *gocache.Cache
} }
func NewDashboardFilereader(cfg *DashboardsAsConfig, log log.Logger) (*fileReader, error) { func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReader, error) {
path, ok := cfg.Options["folder"].(string) path, ok := cfg.Options["folder"].(string)
if !ok { if !ok {
return nil, fmt.Errorf("Failed to load dashboards. folder param is not a string") return nil, fmt.Errorf("Failed to load dashboards. folder param is not a string")
......
...@@ -41,7 +41,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -41,7 +41,7 @@ func TestDashboardFileReader(t *testing.T) {
Convey("Can read default dashboard", func() { Convey("Can read default dashboard", func() {
cfg.Options["folder"] = defaultDashboards cfg.Options["folder"] = defaultDashboards
reader, err := NewDashboardFilereader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.walkFolder() err = reader.walkFolder()
...@@ -58,7 +58,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -58,7 +58,7 @@ func TestDashboardFileReader(t *testing.T) {
Slug: "grafana", Slug: "grafana",
}) })
reader, err := NewDashboardFilereader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.walkFolder() err = reader.walkFolder()
...@@ -77,7 +77,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -77,7 +77,7 @@ func TestDashboardFileReader(t *testing.T) {
Slug: "grafana", Slug: "grafana",
}) })
reader, err := NewDashboardFilereader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.walkFolder() err = reader.walkFolder()
...@@ -94,7 +94,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -94,7 +94,7 @@ func TestDashboardFileReader(t *testing.T) {
Folder: "", Folder: "",
} }
_, err := NewDashboardFilereader(cfg, logger) _, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldNotBeNil) So(err, ShouldNotBeNil)
}) })
...@@ -109,7 +109,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -109,7 +109,7 @@ func TestDashboardFileReader(t *testing.T) {
}, },
} }
_, err := NewDashboardFilereader(cfg, logger) _, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
}) })
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment