Chore: Remove Result from dashboard models (#61997)
* Chore: Remove Result from dashboard models * Fix lint tests * Fix dashboard service tests * Fix API tests * Remove commented out code * Chore: Merge main - cleanup
This commit is contained in:
@@ -102,7 +102,7 @@ func (prov *defaultAlertRuleProvisioner) getOrCreateFolderUID(
|
||||
Slug: slugify.Slugify(folderName),
|
||||
OrgID: orgID,
|
||||
}
|
||||
err := prov.dashboardService.GetDashboard(ctx, cmd)
|
||||
cmdResult, err := prov.dashboardService.GetDashboard(ctx, cmd)
|
||||
if err != nil && !errors.Is(err, dashboards.ErrDashboardNotFound) {
|
||||
return "", err
|
||||
}
|
||||
@@ -123,9 +123,9 @@ func (prov *defaultAlertRuleProvisioner) getOrCreateFolderUID(
|
||||
return dbDash.UID, nil
|
||||
}
|
||||
|
||||
if !cmd.Result.IsFolder {
|
||||
if !cmdResult.IsFolder {
|
||||
return "", fmt.Errorf("got invalid response. expected folder, found dashboard")
|
||||
}
|
||||
|
||||
return cmd.Result.UID, nil
|
||||
return cmdResult.UID, nil
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ func (fr *FileReader) getOrCreateFolderID(ctx context.Context, cfg *config, serv
|
||||
}
|
||||
|
||||
cmd := &dashboards.GetDashboardQuery{Slug: slugify.Slugify(folderName), OrgID: cfg.OrgID}
|
||||
err := fr.dashboardStore.GetDashboard(ctx, cmd)
|
||||
result, err := fr.dashboardStore.GetDashboard(ctx, cmd)
|
||||
|
||||
if err != nil && !errors.Is(err, dashboards.ErrDashboardNotFound) {
|
||||
return 0, err
|
||||
@@ -326,11 +326,11 @@ func (fr *FileReader) getOrCreateFolderID(ctx context.Context, cfg *config, serv
|
||||
return dbDash.ID, nil
|
||||
}
|
||||
|
||||
if !cmd.Result.IsFolder {
|
||||
if !result.IsFolder {
|
||||
return 0, fmt.Errorf("got invalid response. expected folder, found dashboard")
|
||||
}
|
||||
|
||||
return cmd.Result.ID, nil
|
||||
return result.ID, nil
|
||||
}
|
||||
|
||||
func resolveSymlink(fileinfo os.FileInfo, path string) (os.FileInfo, error) {
|
||||
|
||||
@@ -512,6 +512,6 @@ func (ffi FakeFileInfo) Sys() interface{} {
|
||||
|
||||
type fakeDashboardStore struct{}
|
||||
|
||||
func (fds *fakeDashboardStore) GetDashboard(_ context.Context, _ *dashboards.GetDashboardQuery) error {
|
||||
return dashboards.ErrDashboardNotFound
|
||||
func (fds *fakeDashboardStore) GetDashboard(_ context.Context, _ *dashboards.GetDashboardQuery) (*dashboards.Dashboard, error) {
|
||||
return nil, dashboards.ErrDashboardNotFound
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type DashboardStore interface {
|
||||
GetDashboard(context.Context, *dashboards.GetDashboardQuery) error
|
||||
GetDashboard(context.Context, *dashboards.GetDashboardQuery) (*dashboards.Dashboard, error)
|
||||
}
|
||||
|
||||
func CheckOrgExists(ctx context.Context, orgService org.Service, orgID int64) error {
|
||||
|
||||
Reference in New Issue
Block a user