dashboards as cfg: code cleanup

This commit is contained in:
bergquist
2017-11-28 14:01:10 +01:00
parent d69b63cbc0
commit dc0fb8be06
16 changed files with 13 additions and 32 deletions

View File

@@ -4,30 +4,19 @@ import (
"context"
"path/filepath"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/services/provisioning/dashboard"
"github.com/grafana/grafana/pkg/services/provisioning/datasources"
"github.com/grafana/grafana/pkg/services/provisioning/datasource"
ini "gopkg.in/ini.v1"
)
var (
logger log.Logger = log.New("services.provisioning")
)
type Provisioner struct {
datasourcePath string
dashboardPath string
bgContext context.Context
}
func Init(backgroundContext context.Context, homePath string, cfg *ini.File) error {
func Init(ctx context.Context, homePath string, cfg *ini.File) error {
datasourcePath := makeAbsolute(cfg.Section("paths").Key("datasources").String(), homePath)
if err := datasources.Provision(datasourcePath); err != nil {
if err := datasource.Provision(datasourcePath); err != nil {
return err
}
dashboardPath := makeAbsolute(cfg.Section("paths").Key("dashboards").String(), homePath)
_, err := dashboard.Provision(backgroundContext, dashboardPath)
_, err := dashboard.Provision(ctx, dashboardPath)
if err != nil {
return err
}
@@ -35,10 +24,6 @@ func Init(backgroundContext context.Context, homePath string, cfg *ini.File) err
return nil
}
func (p *Provisioner) Listen() error {
return nil
}
func makeAbsolute(path string, root string) string {
if filepath.IsAbs(path) {
return path