Commit 80f40040 by Carl Bergquist Committed by GitHub

Linting fixes for dashboard provsioning (#23576)

parent 010c67cc
......@@ -85,7 +85,8 @@ revive-alerting: scripts/go/bin/revive
@scripts/go/bin/revive \
-formatter stylish \
./pkg/services/alerting/... \
./pkg/services/provisioning/datasources/...
./pkg/services/provisioning/datasources/... \
./pkg/services/provisioning/dashboards/...
scripts/go/bin/golangci-lint: scripts/go/go.mod
@cd scripts/go; \
......
......@@ -113,8 +113,8 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) Response {
}
if provisioningData != nil {
allowUiUpdate := hs.ProvisioningService.GetAllowUiUpdatesFromConfig(provisioningData.Name)
if !allowUiUpdate {
allowUIUpdate := hs.ProvisioningService.GetAllowUIUpdatesFromConfig(provisioningData.Name)
if !allowUIUpdate {
meta.Provisioned = true
}
......@@ -232,7 +232,7 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
allowUiUpdate := true
if provisioningData != nil {
allowUiUpdate = hs.ProvisioningService.GetAllowUiUpdatesFromConfig(provisioningData.Name)
allowUiUpdate = hs.ProvisioningService.GetAllowUIUpdatesFromConfig(provisioningData.Name)
}
dashItem := &dashboards.SaveDashboardDTO{
......
......@@ -964,7 +964,7 @@ func TestDashboardApiEndpoint(t *testing.T) {
mock.GetDashboardProvisionerResolvedPathFunc = func(name string) string {
return "/tmp/grafana/dashboards"
}
mock.GetAllowUiUpdatesFromConfigFunc = func(name string) bool {
mock.GetAllowUIUpdatesFromConfigFunc = func(name string) bool {
return true
}
......
......@@ -92,7 +92,7 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
dashboard.UpdateIntervalSeconds = 10
}
if len(dashboard.FolderUid) > 0 {
uidUsage[dashboard.FolderUid] += 1
uidUsage[dashboard.FolderUid]++
}
}
......
......@@ -9,22 +9,27 @@ import (
"github.com/grafana/grafana/pkg/util/errutil"
)
// DashboardProvisioner is responsible for syncing dashboard from disc to
// Grafanas database.
type DashboardProvisioner interface {
Provision() error
PollChanges(ctx context.Context)
GetProvisionerResolvedPath(name string) string
GetAllowUiUpdatesFromConfig(name string) bool
GetAllowUIUpdatesFromConfig(name string) bool
}
// DashboardProvisionerFactory creates DashboardProvisioners based on input
type DashboardProvisionerFactory func(string) (DashboardProvisioner, error)
type DashboardProvisionerImpl struct {
// Provisioner is responsible for syncing dashboard from disc to Grafanas database.
type Provisioner struct {
log log.Logger
fileReaders []*fileReader
fileReaders []*FileReader
configs []*DashboardsAsConfig
}
func NewDashboardProvisionerImpl(configDirectory string) (*DashboardProvisionerImpl, error) {
// New returns a new DashboardProvisioner
func New(configDirectory string) (*Provisioner, error) {
logger := log.New("provisioning.dashboard")
cfgReader := &configReader{path: configDirectory, log: logger}
configs, err := cfgReader.readConfig()
......@@ -39,7 +44,7 @@ func NewDashboardProvisionerImpl(configDirectory string) (*DashboardProvisionerI
return nil, errutil.Wrap("Failed to initialize file readers", err)
}
d := &DashboardProvisionerImpl{
d := &Provisioner{
log: logger,
fileReaders: fileReaders,
configs: configs,
......@@ -48,7 +53,9 @@ func NewDashboardProvisionerImpl(configDirectory string) (*DashboardProvisionerI
return d, nil
}
func (provider *DashboardProvisionerImpl) Provision() error {
// Provision starts scanning the disc for dashboards and updates
// the database with the latest versions of those dashboards
func (provider *Provisioner) Provision() error {
for _, reader := range provider.fileReaders {
if err := reader.startWalkingDisk(); err != nil {
if os.IsNotExist(err) {
......@@ -66,7 +73,7 @@ func (provider *DashboardProvisionerImpl) Provision() error {
// PollChanges starts polling for changes in dashboard definition files. It creates goroutine for each provider
// defined in the config.
func (provider *DashboardProvisionerImpl) PollChanges(ctx context.Context) {
func (provider *Provisioner) PollChanges(ctx context.Context) {
for _, reader := range provider.fileReaders {
go reader.pollChanges(ctx)
}
......@@ -74,7 +81,7 @@ func (provider *DashboardProvisionerImpl) PollChanges(ctx context.Context) {
// GetProvisionerResolvedPath returns resolved path for the specified provisioner name. Can be used to generate
// relative path to provisioning file from it's external_id.
func (provider *DashboardProvisionerImpl) GetProvisionerResolvedPath(name string) string {
func (provider *Provisioner) GetProvisionerResolvedPath(name string) string {
for _, reader := range provider.fileReaders {
if reader.Cfg.Name == name {
return reader.resolvedPath()
......@@ -83,7 +90,8 @@ func (provider *DashboardProvisionerImpl) GetProvisionerResolvedPath(name string
return ""
}
func (provider *DashboardProvisionerImpl) GetAllowUiUpdatesFromConfig(name string) bool {
// GetAllowUIUpdatesFromConfig return if a dashboard provisioner allows updates from the UI
func (provider *Provisioner) GetAllowUIUpdatesFromConfig(name string) bool {
for _, config := range provider.configs {
if config.Name == name {
return config.AllowUiUpdates
......@@ -92,8 +100,8 @@ func (provider *DashboardProvisionerImpl) GetAllowUiUpdatesFromConfig(name strin
return false
}
func getFileReaders(configs []*DashboardsAsConfig, logger log.Logger) ([]*fileReader, error) {
var readers []*fileReader
func getFileReaders(configs []*DashboardsAsConfig, logger log.Logger) ([]*FileReader, error) {
var readers []*FileReader
for _, config := range configs {
switch config.Type {
......
......@@ -2,28 +2,32 @@ package dashboards
import "context"
type Calls struct {
// Calls is a mock implementation of the provisioner interface
type calls struct {
Provision []interface{}
PollChanges []interface{}
GetProvisionerResolvedPath []interface{}
GetAllowUiUpdatesFromConfig []interface{}
GetAllowUIUpdatesFromConfig []interface{}
}
type DashboardProvisionerMock struct {
Calls *Calls
// ProvisionerMock is a mock implementation of `Provisioner`
type ProvisionerMock struct {
Calls *calls
ProvisionFunc func() error
PollChangesFunc func(ctx context.Context)
GetProvisionerResolvedPathFunc func(name string) string
GetAllowUiUpdatesFromConfigFunc func(name string) bool
GetAllowUIUpdatesFromConfigFunc func(name string) bool
}
func NewDashboardProvisionerMock() *DashboardProvisionerMock {
return &DashboardProvisionerMock{
Calls: &Calls{},
// NewDashboardProvisionerMock returns a new dashboardprovisionermock
func NewDashboardProvisionerMock() *ProvisionerMock {
return &ProvisionerMock{
Calls: &calls{},
}
}
func (dpm *DashboardProvisionerMock) Provision() error {
// Provision is a mock implementation of `Provisioner.Provision`
func (dpm *ProvisionerMock) Provision() error {
dpm.Calls.Provision = append(dpm.Calls.Provision, nil)
if dpm.ProvisionFunc != nil {
return dpm.ProvisionFunc()
......@@ -31,14 +35,16 @@ func (dpm *DashboardProvisionerMock) Provision() error {
return nil
}
func (dpm *DashboardProvisionerMock) PollChanges(ctx context.Context) {
// PollChanges is a mock implementation of `Provisioner.PollChanges`
func (dpm *ProvisionerMock) PollChanges(ctx context.Context) {
dpm.Calls.PollChanges = append(dpm.Calls.PollChanges, ctx)
if dpm.PollChangesFunc != nil {
dpm.PollChangesFunc(ctx)
}
}
func (dpm *DashboardProvisionerMock) GetProvisionerResolvedPath(name string) string {
// GetProvisionerResolvedPath is a mock implementation of `Provisioner.GetProvisionerResolvedPath`
func (dpm *ProvisionerMock) GetProvisionerResolvedPath(name string) string {
dpm.Calls.GetProvisionerResolvedPath = append(dpm.Calls.GetProvisionerResolvedPath, name)
if dpm.GetProvisionerResolvedPathFunc != nil {
return dpm.GetProvisionerResolvedPathFunc(name)
......@@ -46,10 +52,11 @@ func (dpm *DashboardProvisionerMock) GetProvisionerResolvedPath(name string) str
return ""
}
func (dpm *DashboardProvisionerMock) GetAllowUiUpdatesFromConfig(name string) bool {
dpm.Calls.GetAllowUiUpdatesFromConfig = append(dpm.Calls.GetAllowUiUpdatesFromConfig, name)
if dpm.GetAllowUiUpdatesFromConfigFunc != nil {
return dpm.GetAllowUiUpdatesFromConfigFunc(name)
// GetAllowUIUpdatesFromConfig is a mock implementation of `Provisioner.GetAllowUIUpdatesFromConfig`
func (dpm *ProvisionerMock) GetAllowUIUpdatesFromConfig(name string) bool {
dpm.Calls.GetAllowUIUpdatesFromConfig = append(dpm.Calls.GetAllowUIUpdatesFromConfig, name)
if dpm.GetAllowUIUpdatesFromConfigFunc != nil {
return dpm.GetAllowUIUpdatesFromConfigFunc(name)
}
return false
}
......@@ -21,17 +21,22 @@ import (
)
var (
// ErrFolderNameMissing is returned when folder name is missing.
ErrFolderNameMissing = errors.New("Folder name missing")
)
type fileReader struct {
// FileReader is responsible for reading dashboards from disc and
// insert/update dashboards to the Grafana database using
// `dashboards.DashboardProvisioningService`
type FileReader struct {
Cfg *DashboardsAsConfig
Path string
log log.Logger
dashboardProvisioningService dashboards.DashboardProvisioningService
}
func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReader, error) {
// NewDashboardFileReader returns a new filereader based on `DashboardsAsConfig`
func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*FileReader, error) {
var path string
path, ok := cfg.Options["path"].(string)
if !ok {
......@@ -43,7 +48,7 @@ func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReade
log.Warn("[Deprecated] The folder property is deprecated. Please use path instead.")
}
return &fileReader{
return &FileReader{
Cfg: cfg,
Path: path,
log: log,
......@@ -52,7 +57,7 @@ func NewDashboardFileReader(cfg *DashboardsAsConfig, log log.Logger) (*fileReade
}
// pollChanges periodically runs startWalkingDisk 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))
for {
......@@ -69,14 +74,14 @@ func (fr *fileReader) pollChanges(ctx context.Context) {
// startWalkingDisk traverses the file system for defined path, reads dashboard definition files and applies any change
// to the database.
func (fr *fileReader) startWalkingDisk() error {
func (fr *FileReader) startWalkingDisk() error {
fr.log.Debug("Start walking disk", "path", fr.Path)
resolvedPath := fr.resolvedPath()
if _, err := os.Stat(resolvedPath); err != nil {
return err
}
folderId, err := getOrCreateFolderId(fr.Cfg, fr.dashboardProvisioningService)
folderID, err := getOrCreateFolderID(fr.Cfg, fr.dashboardProvisioningService)
if err != nil && err != ErrFolderNameMissing {
return err
}
......@@ -98,7 +103,7 @@ func (fr *fileReader) startWalkingDisk() error {
// save dashboards based on json files
for path, fileInfo := range filesFoundOnDisk {
provisioningMetadata, err := fr.saveDashboard(path, folderId, fileInfo, provisionedDashboardRefs)
provisioningMetadata, err := fr.saveDashboard(path, folderID, fileInfo, provisionedDashboardRefs)
sanityChecker.track(provisioningMetadata)
if err != nil {
fr.log.Error("failed to save dashboard", "error", err)
......@@ -110,7 +115,7 @@ func (fr *fileReader) startWalkingDisk() error {
}
// 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
var dashboardToDelete []int64
for path, provisioningData := range provisionedDashboardRefs {
......@@ -123,27 +128,27 @@ func (fr *fileReader) handleMissingDashboardFiles(provisionedDashboardRefs map[s
if fr.Cfg.DisableDeletion {
// If deletion is disabled for the provisioner we just remove provisioning metadata about the dashboard
// so afterwards the dashboard is considered unprovisioned.
for _, dashboardId := range dashboardToDelete {
fr.log.Debug("unprovisioning provisioned dashboard. missing on disk", "id", dashboardId)
err := fr.dashboardProvisioningService.UnprovisionDashboard(dashboardId)
for _, dashboardID := range dashboardToDelete {
fr.log.Debug("unprovisioning provisioned dashboard. missing on disk", "id", dashboardID)
err := fr.dashboardProvisioningService.UnprovisionDashboard(dashboardID)
if err != nil {
fr.log.Error("failed to unprovision dashboard", "dashboard_id", dashboardId, "error", err)
fr.log.Error("failed to unprovision dashboard", "dashboard_id", dashboardID, "error", err)
}
}
} else {
// delete dashboard that are missing json file
for _, dashboardId := range dashboardToDelete {
fr.log.Debug("deleting provisioned dashboard. missing on disk", "id", dashboardId)
err := fr.dashboardProvisioningService.DeleteProvisionedDashboard(dashboardId, fr.Cfg.OrgId)
for _, dashboardID := range dashboardToDelete {
fr.log.Debug("deleting provisioned dashboard. missing on disk", "id", dashboardID)
err := fr.dashboardProvisioningService.DeleteProvisionedDashboard(dashboardID, fr.Cfg.OrgId)
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)
}
}
}
}
// 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{}
resolvedFileInfo, err := resolveSymlink(fileInfo, path)
if err != nil {
......@@ -153,7 +158,7 @@ func (fr *fileReader) saveDashboard(path string, folderId int64, fileInfo os.Fil
provisionedData, alreadyProvisioned := provisionedDashboardRefs[path]
upToDate := alreadyProvisioned && provisionedData.Updated >= resolvedFileInfo.ModTime().Unix()
jsonFile, err := fr.readDashboardFromFile(path, resolvedFileInfo.ModTime(), folderId)
jsonFile, err := fr.readDashboardFromFile(path, resolvedFileInfo.ModTime(), folderID)
if err != nil {
fr.log.Error("failed to load dashboard from ", "file", path, "error", err)
return provisioningMetadata, nil
......@@ -207,7 +212,7 @@ func getProvisionedDashboardByPath(service dashboards.DashboardProvisioningServi
return byPath, nil
}
func getOrCreateFolderId(cfg *DashboardsAsConfig, service dashboards.DashboardProvisioningService) (int64, error) {
func getOrCreateFolderID(cfg *DashboardsAsConfig, service dashboards.DashboardProvisioningService) (int64, error) {
if cfg.Folder == "" {
return 0, ErrFolderNameMissing
}
......@@ -288,13 +293,13 @@ func validateWalkablePath(fileInfo os.FileInfo) (bool, error) {
return true, nil
}
type dashboardJsonFile struct {
type dashboardJSONFile struct {
dashboard *dashboards.SaveDashboardDTO
checkSum string
lastModified time.Time
}
func (fr *fileReader) readDashboardFromFile(path string, lastModified time.Time, folderId int64) (*dashboardJsonFile, error) {
func (fr *FileReader) readDashboardFromFile(path string, lastModified time.Time, folderID int64) (*dashboardJSONFile, error) {
reader, err := os.Open(path)
if err != nil {
return nil, err
......@@ -316,19 +321,19 @@ func (fr *fileReader) readDashboardFromFile(path string, lastModified time.Time,
return nil, err
}
dash, err := createDashboardJson(data, lastModified, fr.Cfg, folderId)
dash, err := createDashboardJson(data, lastModified, fr.Cfg, folderID)
if err != nil {
return nil, err
}
return &dashboardJsonFile{
return &dashboardJSONFile{
dashboard: dash,
checkSum: checkSum,
lastModified: lastModified,
}, nil
}
func (fr *fileReader) resolvedPath() string {
func (fr *FileReader) resolvedPath() string {
if _, err := os.Stat(fr.Path); os.IsNotExist(err) {
fr.log.Error("Cannot read directory", "error", err)
}
......@@ -370,10 +375,10 @@ type provisioningSanityChecker struct {
func (checker provisioningSanityChecker) track(pm provisioningMetadata) {
if len(pm.uid) > 0 {
checker.uidUsage[pm.uid] += 1
checker.uidUsage[pm.uid]++
}
if len(pm.title) > 0 {
checker.titleUsage[pm.title] += 1
checker.titleUsage[pm.title]++
}
}
......
......@@ -27,7 +27,7 @@ func TestProvsionedSymlinkedFolder(t *testing.T) {
t.Error("expected err to be nil")
}
want, err := filepath.Abs(containingId)
want, err := filepath.Abs(containingID)
if err != nil {
t.Errorf("expected err to be nil")
......
package dashboards
import (
"github.com/grafana/grafana/pkg/util"
"math/rand"
"os"
"path/filepath"
......@@ -9,6 +8,8 @@ import (
"testing"
"time"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboards"
......@@ -21,7 +22,7 @@ var (
defaultDashboards = "testdata/test-dashboards/folder-one"
brokenDashboards = "testdata/test-dashboards/broken-dashboards"
oneDashboard = "testdata/test-dashboards/one-dashboard"
containingId = "testdata/test-dashboards/containing-id"
containingID = "testdata/test-dashboards/containing-id"
unprovision = "testdata/test-dashboards/unprovision"
fakeService *fakeDashboardProvisioningService
......@@ -140,7 +141,7 @@ func TestDashboardFileReader(t *testing.T) {
})
Convey("Overrides id from dashboard.json files", func() {
cfg.Options["path"] = containingId
cfg.Options["path"] = containingID
reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil)
......@@ -171,8 +172,8 @@ func TestDashboardFileReader(t *testing.T) {
})
Convey("Two dashboard providers should be able to provisioned the same dashboard without uid", func() {
cfg1 := &DashboardsAsConfig{Name: "1", Type: "file", OrgId: 1, Folder: "f1", Options: map[string]interface{}{"path": containingId}}
cfg2 := &DashboardsAsConfig{Name: "2", Type: "file", OrgId: 1, Folder: "f2", Options: map[string]interface{}{"path": containingId}}
cfg1 := &DashboardsAsConfig{Name: "1", Type: "file", OrgId: 1, Folder: "f1", Options: map[string]interface{}{"path": containingID}}
cfg2 := &DashboardsAsConfig{Name: "2", Type: "file", OrgId: 1, Folder: "f2", Options: map[string]interface{}{"path": containingID}}
reader1, err := NewDashboardFileReader(cfg1, logger)
So(err, ShouldBeNil)
......@@ -212,7 +213,7 @@ func TestDashboardFileReader(t *testing.T) {
},
}
_, err := getOrCreateFolderId(cfg, fakeService)
_, err := getOrCreateFolderID(cfg, fakeService)
So(err, ShouldEqual, ErrFolderNameMissing)
})
......@@ -227,11 +228,11 @@ func TestDashboardFileReader(t *testing.T) {
},
}
folderId, err := getOrCreateFolderId(cfg, fakeService)
folderID, err := getOrCreateFolderID(cfg, fakeService)
So(err, ShouldBeNil)
inserted := false
for _, d := range fakeService.inserted {
if d.Dashboard.IsFolder && d.Dashboard.Id == folderId {
if d.Dashboard.IsFolder && d.Dashboard.Id == folderID {
inserted = true
}
}
......@@ -410,10 +411,10 @@ func (s *fakeDashboardProvisioningService) SaveFolderForProvisionedDashboards(dt
return dto.Dashboard, nil
}
func (s *fakeDashboardProvisioningService) UnprovisionDashboard(dashboardId int64) error {
func (s *fakeDashboardProvisioningService) UnprovisionDashboard(dashboardID int64) error {
for key, val := range s.provisioned {
for index, dashboard := range val {
if dashboard.DashboardId == dashboardId {
if dashboard.DashboardId == dashboardID {
s.provisioned[key] = append(s.provisioned[key][:index], s.provisioned[key][index+1:]...)
}
}
......@@ -421,21 +422,21 @@ func (s *fakeDashboardProvisioningService) UnprovisionDashboard(dashboardId int6
return nil
}
func (s *fakeDashboardProvisioningService) DeleteProvisionedDashboard(dashboardId int64, orgId int64) error {
err := s.UnprovisionDashboard(dashboardId)
func (s *fakeDashboardProvisioningService) DeleteProvisionedDashboard(dashboardID int64, orgID int64) error {
err := s.UnprovisionDashboard(dashboardID)
if err != nil {
return err
}
for index, val := range s.inserted {
if val.Dashboard.Id == dashboardId {
if val.Dashboard.Id == dashboardID {
s.inserted = append(s.inserted[:index], s.inserted[util.MinInt(index+1, len(s.inserted)):]...)
}
}
return nil
}
func (s *fakeDashboardProvisioningService) GetProvisionedDashboardDataByDashboardId(dashboardId int64) (*models.DashboardProvisioning, error) {
func (s *fakeDashboardProvisioningService) GetProvisionedDashboardDataByDashboardId(dashboardID int64) (*models.DashboardProvisioning, error) {
return nil, nil
}
......
......@@ -20,13 +20,13 @@ type ProvisioningService interface {
ProvisionNotifications() error
ProvisionDashboards() error
GetDashboardProvisionerResolvedPath(name string) string
GetAllowUiUpdatesFromConfig(name string) bool
GetAllowUIUpdatesFromConfig(name string) bool
}
func init() {
registry.RegisterService(NewProvisioningServiceImpl(
func(path string) (dashboards.DashboardProvisioner, error) {
return dashboards.NewDashboardProvisionerImpl(path)
return dashboards.New(path)
},
notifiers.Provision,
datasources.Provision,
......@@ -138,8 +138,8 @@ func (ps *provisioningServiceImpl) GetDashboardProvisionerResolvedPath(name stri
return ps.dashboardProvisioner.GetProvisionerResolvedPath(name)
}
func (ps *provisioningServiceImpl) GetAllowUiUpdatesFromConfig(name string) bool {
return ps.dashboardProvisioner.GetAllowUiUpdatesFromConfig(name)
func (ps *provisioningServiceImpl) GetAllowUIUpdatesFromConfig(name string) bool {
return ps.dashboardProvisioner.GetAllowUIUpdatesFromConfig(name)
}
func (ps *provisioningServiceImpl) cancelPolling() {
......
......@@ -5,7 +5,7 @@ type Calls struct {
ProvisionNotifications []interface{}
ProvisionDashboards []interface{}
GetDashboardProvisionerResolvedPath []interface{}
GetAllowUiUpdatesFromConfig []interface{}
GetAllowUIUpdatesFromConfig []interface{}
}
type ProvisioningServiceMock struct {
......@@ -14,7 +14,7 @@ type ProvisioningServiceMock struct {
ProvisionNotificationsFunc func() error
ProvisionDashboardsFunc func() error
GetDashboardProvisionerResolvedPathFunc func(name string) string
GetAllowUiUpdatesFromConfigFunc func(name string) bool
GetAllowUIUpdatesFromConfigFunc func(name string) bool
}
func NewProvisioningServiceMock() *ProvisioningServiceMock {
......@@ -55,10 +55,10 @@ func (mock *ProvisioningServiceMock) GetDashboardProvisionerResolvedPath(name st
return ""
}
func (mock *ProvisioningServiceMock) GetAllowUiUpdatesFromConfig(name string) bool {
mock.Calls.GetAllowUiUpdatesFromConfig = append(mock.Calls.GetAllowUiUpdatesFromConfig, name)
if mock.GetAllowUiUpdatesFromConfigFunc != nil {
return mock.GetAllowUiUpdatesFromConfigFunc(name)
func (mock *ProvisioningServiceMock) GetAllowUIUpdatesFromConfig(name string) bool {
mock.Calls.GetAllowUIUpdatesFromConfig = append(mock.Calls.GetAllowUIUpdatesFromConfig, name)
if mock.GetAllowUIUpdatesFromConfigFunc != nil {
return mock.GetAllowUIUpdatesFromConfigFunc(name)
}
return false
}
......@@ -75,7 +75,7 @@ type serviceTestStruct struct {
startService func()
cancel func()
mock *dashboards.DashboardProvisionerMock
mock *dashboards.ProvisionerMock
service *provisioningServiceImpl
}
......
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