Commit 116809ed by Arve Knudsen Committed by GitHub

services/provisioning: Various cleanup (#30396)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 9691af83
...@@ -81,7 +81,8 @@ func (dr *dashboardServiceImpl) GetProvisionedDashboardDataByDashboardID(dashboa ...@@ -81,7 +81,8 @@ func (dr *dashboardServiceImpl) GetProvisionedDashboardDataByDashboardID(dashboa
return cmd.Result, nil return cmd.Result, nil
} }
func (dr *dashboardServiceImpl) buildSaveDashboardCommand(dto *SaveDashboardDTO, validateAlerts bool, validateProvisionedDashboard bool) (*models.SaveDashboardCommand, error) { func (dr *dashboardServiceImpl) buildSaveDashboardCommand(dto *SaveDashboardDTO, validateAlerts bool,
validateProvisionedDashboard bool) (*models.SaveDashboardCommand, error) {
dash := dto.Dashboard dash := dto.Dashboard
dash.Title = strings.TrimSpace(dash.Title) dash.Title = strings.TrimSpace(dash.Title)
...@@ -216,9 +217,11 @@ func (dr *dashboardServiceImpl) updateAlerting(cmd *models.SaveDashboardCommand, ...@@ -216,9 +217,11 @@ func (dr *dashboardServiceImpl) updateAlerting(cmd *models.SaveDashboardCommand,
return bus.Dispatch(&alertCmd) return bus.Dispatch(&alertCmd)
} }
func (dr *dashboardServiceImpl) SaveProvisionedDashboard(dto *SaveDashboardDTO, provisioning *models.DashboardProvisioning) (*models.Dashboard, error) { func (dr *dashboardServiceImpl) SaveProvisionedDashboard(dto *SaveDashboardDTO,
provisioning *models.DashboardProvisioning) (*models.Dashboard, error) {
if err := validateDashboardRefreshInterval(dto.Dashboard); err != nil { if err := validateDashboardRefreshInterval(dto.Dashboard); err != nil {
dr.log.Warn("Changing refresh interval for provisioned dashboard to minimum refresh interval", "dashboardUid", dto.Dashboard.Uid, "dashboardTitle", dto.Dashboard.Title, "minRefreshInterval", setting.MinRefreshInterval) dr.log.Warn("Changing refresh interval for provisioned dashboard to minimum refresh interval", "dashboardUid",
dto.Dashboard.Uid, "dashboardTitle", dto.Dashboard.Title, "minRefreshInterval", setting.MinRefreshInterval)
dto.Dashboard.Data.Set("refresh", setting.MinRefreshInterval) dto.Dashboard.Data.Set("refresh", setting.MinRefreshInterval)
} }
......
...@@ -74,7 +74,7 @@ func IsEnabled() bool { ...@@ -74,7 +74,7 @@ func IsEnabled() bool {
return setting.LDAPEnabled return setting.LDAPEnabled
} }
// ReloadConfig reads the config from the disc and caches it. // ReloadConfig reads the config from the disk and caches it.
func ReloadConfig() error { func ReloadConfig() error {
if !IsEnabled() { if !IsEnabled() {
return nil return nil
......
...@@ -110,7 +110,7 @@ func (cr *configReader) readConfig() ([]*config, error) { ...@@ -110,7 +110,7 @@ func (cr *configReader) readConfig() ([]*config, error) {
for uid, times := range uidUsage { for uid, times := range uidUsage {
if times > 1 { if times > 1 {
cr.log.Error("the same 'folderUid' is used more than once", "folderUid", uid) cr.log.Error("the same folder UID is used more than once", "folderUid", uid)
} }
} }
......
...@@ -11,8 +11,8 @@ import ( ...@@ -11,8 +11,8 @@ import (
"github.com/grafana/grafana/pkg/util/errutil" "github.com/grafana/grafana/pkg/util/errutil"
) )
// DashboardProvisioner is responsible for syncing dashboard from disc to // DashboardProvisioner is responsible for syncing dashboard from disk to
// Grafanas database. // Grafana's database.
type DashboardProvisioner interface { type DashboardProvisioner interface {
Provision() error Provision() error
PollChanges(ctx context.Context) PollChanges(ctx context.Context)
...@@ -24,7 +24,7 @@ type DashboardProvisioner interface { ...@@ -24,7 +24,7 @@ type DashboardProvisioner interface {
// DashboardProvisionerFactory creates DashboardProvisioners based on input // DashboardProvisionerFactory creates DashboardProvisioners based on input
type DashboardProvisionerFactory func(string) (DashboardProvisioner, error) type DashboardProvisionerFactory func(string) (DashboardProvisioner, error)
// Provisioner is responsible for syncing dashboard from disc to Grafanas database. // Provisioner is responsible for syncing dashboard from disk to Grafana's database.
type Provisioner struct { type Provisioner struct {
log log.Logger log log.Logger
fileReaders []*FileReader fileReaders []*FileReader
...@@ -42,7 +42,6 @@ func New(configDirectory string) (*Provisioner, error) { ...@@ -42,7 +42,6 @@ func New(configDirectory string) (*Provisioner, error) {
} }
fileReaders, err := getFileReaders(configs, logger) fileReaders, err := getFileReaders(configs, logger)
if err != nil { if err != nil {
return nil, errutil.Wrap("Failed to initialize file readers", err) return nil, errutil.Wrap("Failed to initialize file readers", err)
} }
...@@ -56,11 +55,11 @@ func New(configDirectory string) (*Provisioner, error) { ...@@ -56,11 +55,11 @@ func New(configDirectory string) (*Provisioner, error) {
return d, nil return d, nil
} }
// Provision starts scanning the disc for dashboards and updates // Provision scans the disk for dashboards and updates
// the database with the latest versions of those dashboards // the database with the latest versions of those dashboards.
func (provider *Provisioner) Provision() error { func (provider *Provisioner) Provision() error {
for _, reader := range provider.fileReaders { for _, reader := range provider.fileReaders {
if err := reader.startWalkingDisk(); err != nil { if err := reader.walkDisk(); err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
// don't stop the provisioning service in case the folder is missing. The folder can appear after the startup // don't stop the provisioning service in case the folder is missing. The folder can appear after the startup
provider.log.Warn("Failed to provision config", "name", reader.Cfg.Name, "error", err) provider.log.Warn("Failed to provision config", "name", reader.Cfg.Name, "error", err)
...@@ -87,7 +86,7 @@ func (provider *Provisioner) CleanUpOrphanedDashboards() { ...@@ -87,7 +86,7 @@ func (provider *Provisioner) CleanUpOrphanedDashboards() {
} }
} }
// PollChanges starts polling for changes in dashboard definition files. It creates goroutine for each provider // PollChanges starts polling for changes in dashboard definition files. It creates a goroutine for each provider
// defined in the config. // defined in the config.
func (provider *Provisioner) PollChanges(ctx context.Context) { func (provider *Provisioner) PollChanges(ctx context.Context) {
for _, reader := range provider.fileReaders { for _, reader := range provider.fileReaders {
......
...@@ -23,9 +23,9 @@ var ( ...@@ -23,9 +23,9 @@ var (
ErrFolderNameMissing = errors.New("folder name missing") ErrFolderNameMissing = errors.New("folder name missing")
) )
// FileReader is responsible for reading dashboards from disc and // FileReader is responsible for reading dashboards from disk and
// insert/update dashboards to the Grafana database using // insert/update dashboards to the Grafana database using
// `dashboards.DashboardProvisioningService` // `dashboards.DashboardProvisioningService`.
type FileReader struct { type FileReader struct {
Cfg *config Cfg *config
Path string Path string
...@@ -61,13 +61,13 @@ func NewDashboardFileReader(cfg *config, log log.Logger) (*FileReader, error) { ...@@ -61,13 +61,13 @@ func NewDashboardFileReader(cfg *config, log log.Logger) (*FileReader, error) {
}, nil }, nil
} }
// pollChanges periodically runs startWalkingDisk based on interval specified in the config. // pollChanges periodically runs walkDisk based on interval specified in the config.
func (fr *FileReader) pollChanges(ctx context.Context) { func (fr *FileReader) pollChanges(ctx context.Context) {
ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.UpdateIntervalSeconds)) ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.UpdateIntervalSeconds))
for { for {
select { select {
case <-ticker.C: case <-ticker.C:
if err := fr.startWalkingDisk(); err != nil { if err := fr.walkDisk(); err != nil {
fr.log.Error("failed to search for dashboards", "error", err) fr.log.Error("failed to search for dashboards", "error", err)
} }
case <-ctx.Done(): case <-ctx.Done():
...@@ -76,23 +76,23 @@ func (fr *FileReader) pollChanges(ctx context.Context) { ...@@ -76,23 +76,23 @@ func (fr *FileReader) pollChanges(ctx context.Context) {
} }
} }
// startWalkingDisk traverses the file system for defined path, reads dashboard definition files and applies any change // walkDisk traverses the file system for the defined path, reading dashboard definition files,
// to the database. // and applies any change to the database.
func (fr *FileReader) startWalkingDisk() error { func (fr *FileReader) walkDisk() error {
fr.log.Debug("Start walking disk", "path", fr.Path) fr.log.Debug("Start walking disk", "path", fr.Path)
resolvedPath := fr.resolvedPath() resolvedPath := fr.resolvedPath()
if _, err := os.Stat(resolvedPath); err != nil { if _, err := os.Stat(resolvedPath); err != nil {
return err return err
} }
provisionedDashboardRefs, err := getProvisionedDashboardByPath(fr.dashboardProvisioningService, fr.Cfg.Name) provisionedDashboardRefs, err := getProvisionedDashboardsByPath(fr.dashboardProvisioningService, fr.Cfg.Name)
if err != nil { if err != nil {
return err return err
} }
// Find relevant files
filesFoundOnDisk := map[string]os.FileInfo{} filesFoundOnDisk := map[string]os.FileInfo{}
err = filepath.Walk(resolvedPath, createWalkFn(filesFoundOnDisk)) if err := filepath.Walk(resolvedPath, createWalkFn(filesFoundOnDisk)); err != nil {
if err != nil {
return err return err
} }
...@@ -115,7 +115,8 @@ func (fr *FileReader) startWalkingDisk() error { ...@@ -115,7 +115,8 @@ func (fr *FileReader) startWalkingDisk() error {
} }
// storeDashboardsInFolder saves dashboards from the filesystem on disk to the folder from config // storeDashboardsInFolder saves dashboards from the filesystem on disk to the folder from config
func (fr *FileReader) storeDashboardsInFolder(filesFoundOnDisk map[string]os.FileInfo, dashboardRefs map[string]*models.DashboardProvisioning, sanityChecker *provisioningSanityChecker) error { func (fr *FileReader) storeDashboardsInFolder(filesFoundOnDisk map[string]os.FileInfo,
dashboardRefs map[string]*models.DashboardProvisioning, sanityChecker *provisioningSanityChecker) error {
folderID, err := getOrCreateFolderID(fr.Cfg, fr.dashboardProvisioningService, fr.Cfg.Folder) folderID, err := getOrCreateFolderID(fr.Cfg, fr.dashboardProvisioningService, fr.Cfg.Folder)
if err != nil && !errors.Is(err, ErrFolderNameMissing) { if err != nil && !errors.Is(err, ErrFolderNameMissing) {
return err return err
...@@ -124,17 +125,20 @@ func (fr *FileReader) storeDashboardsInFolder(filesFoundOnDisk map[string]os.Fil ...@@ -124,17 +125,20 @@ func (fr *FileReader) storeDashboardsInFolder(filesFoundOnDisk map[string]os.Fil
// save dashboards based on json files // save dashboards based on json files
for path, fileInfo := range filesFoundOnDisk { for path, fileInfo := range filesFoundOnDisk {
provisioningMetadata, err := fr.saveDashboard(path, folderID, fileInfo, dashboardRefs) provisioningMetadata, err := fr.saveDashboard(path, folderID, fileInfo, dashboardRefs)
sanityChecker.track(provisioningMetadata)
if err != nil { if err != nil {
fr.log.Error("failed to save dashboard", "error", err) fr.log.Error("failed to save dashboard", "error", err)
continue
} }
sanityChecker.track(provisioningMetadata)
} }
return nil return nil
} }
// storeDashboardsInFoldersFromFilesystemStructure saves dashboards from the filesystem on disk to the same folder // storeDashboardsInFoldersFromFilesystemStructure saves dashboards from the filesystem on disk to the same folder
// in grafana as they are in on the filesystem // in Grafana as they are in on the filesystem.
func (fr *FileReader) storeDashboardsInFoldersFromFileStructure(filesFoundOnDisk map[string]os.FileInfo, dashboardRefs map[string]*models.DashboardProvisioning, resolvedPath string, sanityChecker *provisioningSanityChecker) error { func (fr *FileReader) storeDashboardsInFoldersFromFileStructure(filesFoundOnDisk map[string]os.FileInfo,
dashboardRefs map[string]*models.DashboardProvisioning, resolvedPath string, sanityChecker *provisioningSanityChecker) error {
for path, fileInfo := range filesFoundOnDisk { for path, fileInfo := range filesFoundOnDisk {
folderName := "" folderName := ""
...@@ -158,20 +162,21 @@ func (fr *FileReader) storeDashboardsInFoldersFromFileStructure(filesFoundOnDisk ...@@ -158,20 +162,21 @@ func (fr *FileReader) storeDashboardsInFoldersFromFileStructure(filesFoundOnDisk
} }
// handleMissingDashboardFiles will unprovision or delete dashboards which are missing on disk. // handleMissingDashboardFiles will unprovision or delete dashboards which are missing on disk.
func (fr *FileReader) handleMissingDashboardFiles(provisionedDashboardRefs map[string]*models.DashboardProvisioning, filesFoundOnDisk map[string]os.FileInfo) { func (fr *FileReader) handleMissingDashboardFiles(provisionedDashboardRefs map[string]*models.DashboardProvisioning,
filesFoundOnDisk map[string]os.FileInfo) {
// find dashboards to delete since json file is missing // find dashboards to delete since json file is missing
var dashboardToDelete []int64 var dashboardsToDelete []int64
for path, provisioningData := range provisionedDashboardRefs { for path, provisioningData := range provisionedDashboardRefs {
_, existsOnDisk := filesFoundOnDisk[path] _, existsOnDisk := filesFoundOnDisk[path]
if !existsOnDisk { if !existsOnDisk {
dashboardToDelete = append(dashboardToDelete, provisioningData.DashboardId) dashboardsToDelete = append(dashboardsToDelete, provisioningData.DashboardId)
} }
} }
if fr.Cfg.DisableDeletion { if fr.Cfg.DisableDeletion {
// If deletion is disabled for the provisioner we just remove provisioning metadata about the dashboard // If deletion is disabled for the provisioner we just remove provisioning metadata about the dashboard
// so afterwards the dashboard is considered unprovisioned. // so afterwards the dashboard is considered unprovisioned.
for _, dashboardID := range dashboardToDelete { for _, dashboardID := range dashboardsToDelete {
fr.log.Debug("unprovisioning provisioned dashboard. missing on disk", "id", dashboardID) fr.log.Debug("unprovisioning provisioned dashboard. missing on disk", "id", dashboardID)
err := fr.dashboardProvisioningService.UnprovisionDashboard(dashboardID) err := fr.dashboardProvisioningService.UnprovisionDashboard(dashboardID)
if err != nil { if err != nil {
...@@ -179,9 +184,9 @@ func (fr *FileReader) handleMissingDashboardFiles(provisionedDashboardRefs map[s ...@@ -179,9 +184,9 @@ func (fr *FileReader) handleMissingDashboardFiles(provisionedDashboardRefs map[s
} }
} }
} else { } else {
// delete dashboard that are missing json file // delete dashboards missing JSON file
for _, dashboardID := range dashboardToDelete { for _, dashboardID := range dashboardsToDelete {
fr.log.Debug("deleting provisioned dashboard. missing on disk", "id", dashboardID) fr.log.Debug("deleting provisioned dashboard, missing on disk", "id", dashboardID)
err := fr.dashboardProvisioningService.DeleteProvisionedDashboard(dashboardID, fr.Cfg.OrgID) err := fr.dashboardProvisioningService.DeleteProvisionedDashboard(dashboardID, fr.Cfg.OrgID)
if err != nil { if err != nil {
fr.log.Error("failed to delete dashboard", "id", dashboardID, "error", err) fr.log.Error("failed to delete dashboard", "id", dashboardID, "error", err)
...@@ -191,7 +196,8 @@ func (fr *FileReader) handleMissingDashboardFiles(provisionedDashboardRefs map[s ...@@ -191,7 +196,8 @@ func (fr *FileReader) handleMissingDashboardFiles(provisionedDashboardRefs map[s
} }
// saveDashboard saves or updates the dashboard provisioning file at path. // saveDashboard saves or updates the dashboard provisioning file at path.
func (fr *FileReader) saveDashboard(path string, folderID int64, fileInfo os.FileInfo, provisionedDashboardRefs map[string]*models.DashboardProvisioning) (provisioningMetadata, error) { func (fr *FileReader) saveDashboard(path string, folderID int64, fileInfo os.FileInfo,
provisionedDashboardRefs map[string]*models.DashboardProvisioning) (provisioningMetadata, error) {
provisioningMetadata := provisioningMetadata{} provisioningMetadata := provisioningMetadata{}
resolvedFileInfo, err := resolveSymlink(fileInfo, path) resolvedFileInfo, err := resolveSymlink(fileInfo, path)
if err != nil { if err != nil {
...@@ -211,7 +217,7 @@ func (fr *FileReader) saveDashboard(path string, folderID int64, fileInfo os.Fil ...@@ -211,7 +217,7 @@ func (fr *FileReader) saveDashboard(path string, folderID int64, fileInfo os.Fil
upToDate = true upToDate = true
} }
// keeps track of what uid's and title's we have already provisioned // keeps track of which UIDs and titles we have already provisioned
dash := jsonFile.dashboard dash := jsonFile.dashboard
provisioningMetadata.uid = dash.Dashboard.Uid provisioningMetadata.uid = dash.Dashboard.Uid
provisioningMetadata.identity = dashboardIdentity{title: dash.Dashboard.Title, folderID: dash.Dashboard.FolderId} provisioningMetadata.identity = dashboardIdentity{title: dash.Dashboard.Title, folderID: dash.Dashboard.FolderId}
...@@ -241,7 +247,8 @@ func (fr *FileReader) saveDashboard(path string, folderID int64, fileInfo os.Fil ...@@ -241,7 +247,8 @@ func (fr *FileReader) saveDashboard(path string, folderID int64, fileInfo os.Fil
return provisioningMetadata, err return provisioningMetadata, err
} }
func getProvisionedDashboardByPath(service dashboards.DashboardProvisioningService, name string) (map[string]*models.DashboardProvisioning, error) { func getProvisionedDashboardsByPath(service dashboards.DashboardProvisioningService, name string) (
map[string]*models.DashboardProvisioning, error) {
arr, err := service.GetProvisionedDashboardData(name) arr, err := service.GetProvisionedDashboardData(name)
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -18,17 +18,17 @@ import ( ...@@ -18,17 +18,17 @@ import (
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
) )
var ( const (
defaultDashboards = "testdata/test-dashboards/folder-one" defaultDashboards = "testdata/test-dashboards/folder-one"
brokenDashboards = "testdata/test-dashboards/broken-dashboards" brokenDashboards = "testdata/test-dashboards/broken-dashboards"
oneDashboard = "testdata/test-dashboards/one-dashboard" oneDashboard = "testdata/test-dashboards/one-dashboard"
containingID = "testdata/test-dashboards/containing-id" containingID = "testdata/test-dashboards/containing-id"
unprovision = "testdata/test-dashboards/unprovision" unprovision = "testdata/test-dashboards/unprovision"
foldersFromFilesStructure = "testdata/test-dashboards/folders-from-files-structure" foldersFromFilesStructure = "testdata/test-dashboards/folders-from-files-structure"
fakeService *fakeDashboardProvisioningService
) )
var fakeService *fakeDashboardProvisioningService
func TestCreatingNewDashboardFileReader(t *testing.T) { func TestCreatingNewDashboardFileReader(t *testing.T) {
Convey("creating new dashboard file reader", t, func() { Convey("creating new dashboard file reader", t, func() {
cfg := &config{ cfg := &config{
...@@ -111,7 +111,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -111,7 +111,7 @@ func TestDashboardFileReader(t *testing.T) {
reader, err := NewDashboardFileReader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.startWalkingDisk() err = reader.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
folders := 0 folders := 0
...@@ -142,7 +142,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -142,7 +142,7 @@ func TestDashboardFileReader(t *testing.T) {
reader, err := NewDashboardFileReader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.startWalkingDisk() err = reader.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(fakeService.inserted), ShouldEqual, 1) So(len(fakeService.inserted), ShouldEqual, 1)
...@@ -154,7 +154,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -154,7 +154,7 @@ func TestDashboardFileReader(t *testing.T) {
reader, err := NewDashboardFileReader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.startWalkingDisk() err = reader.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(fakeService.inserted), ShouldEqual, 1) So(len(fakeService.inserted), ShouldEqual, 1)
...@@ -167,7 +167,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -167,7 +167,7 @@ func TestDashboardFileReader(t *testing.T) {
reader, err := NewDashboardFileReader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.startWalkingDisk() err = reader.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(fakeService.inserted), ShouldEqual, 5) So(len(fakeService.inserted), ShouldEqual, 5)
...@@ -226,13 +226,13 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -226,13 +226,13 @@ func TestDashboardFileReader(t *testing.T) {
reader1, err := NewDashboardFileReader(cfg1, logger) reader1, err := NewDashboardFileReader(cfg1, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader1.startWalkingDisk() err = reader1.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
reader2, err := NewDashboardFileReader(cfg2, logger) reader2, err := NewDashboardFileReader(cfg2, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader2.startWalkingDisk() err = reader2.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
var folderCount int var folderCount int
...@@ -319,7 +319,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -319,7 +319,7 @@ func TestDashboardFileReader(t *testing.T) {
absPath1, err := filepath.Abs(unprovision + "/dashboard1.json") absPath1, err := filepath.Abs(unprovision + "/dashboard1.json")
So(err, ShouldBeNil) So(err, ShouldBeNil)
// This one does not exist on disc, simulating a deleted file // This one does not exist on disk, simulating a deleted file
absPath2, err := filepath.Abs(unprovision + "/dashboard2.json") absPath2, err := filepath.Abs(unprovision + "/dashboard2.json")
So(err, ShouldBeNil) So(err, ShouldBeNil)
...@@ -336,7 +336,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -336,7 +336,7 @@ func TestDashboardFileReader(t *testing.T) {
reader, err := NewDashboardFileReader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.startWalkingDisk() err = reader.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(fakeService.provisioned["Default"]), ShouldEqual, 1) So(len(fakeService.provisioned["Default"]), ShouldEqual, 1)
...@@ -347,7 +347,7 @@ func TestDashboardFileReader(t *testing.T) { ...@@ -347,7 +347,7 @@ func TestDashboardFileReader(t *testing.T) {
reader, err := NewDashboardFileReader(cfg, logger) reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = reader.startWalkingDisk() err = reader.walkDisk()
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(fakeService.provisioned["Default"]), ShouldEqual, 1) So(len(fakeService.provisioned["Default"]), ShouldEqual, 1)
......
...@@ -38,7 +38,6 @@ func GetProvisionedDataByDashboardId(cmd *models.GetProvisionedDashboardDataById ...@@ -38,7 +38,6 @@ func GetProvisionedDataByDashboardId(cmd *models.GetProvisionedDashboardDataById
func SaveProvisionedDashboard(cmd *models.SaveProvisionedDashboardCommand) error { func SaveProvisionedDashboard(cmd *models.SaveProvisionedDashboardCommand) error {
return inTransaction(func(sess *DBSession) error { return inTransaction(func(sess *DBSession) error {
err := saveDashboard(sess, cmd.DashboardCmd) err := saveDashboard(sess, cmd.DashboardCmd)
if err != nil { if err != nil {
return err return err
} }
......
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