Dashboards: Evaluate provisioned dashboard titles in a backwards compatible way (#65184)

This commit is contained in:
Emil Tullstedt
2023-03-28 13:24:19 +02:00
committed by GitHub
parent 3335d46c5f
commit b210a39cb7
5 changed files with 68 additions and 16 deletions

View File

@@ -6,7 +6,6 @@ import (
"fmt"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/slugify"
"github.com/grafana/grafana/pkg/services/dashboards"
alert_models "github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/provisioning"
@@ -97,8 +96,9 @@ func (prov *defaultAlertRuleProvisioner) provisionRule(
func (prov *defaultAlertRuleProvisioner) getOrCreateFolderUID(
ctx context.Context, folderName string, orgID int64) (string, error) {
cmd := &dashboards.GetDashboardQuery{
Slug: slugify.Slugify(folderName),
OrgID: orgID,
Title: &folderName,
FolderID: util.Pointer(int64(0)),
OrgID: orgID,
}
cmdResult, err := prov.dashboardService.GetDashboard(ctx, cmd)
if err != nil && !errors.Is(err, dashboards.ErrDashboardNotFound) {

View File

@@ -13,7 +13,6 @@ import (
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/slugify"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/provisioning/utils"
@@ -299,7 +298,11 @@ func (fr *FileReader) getOrCreateFolderID(ctx context.Context, cfg *config, serv
return 0, ErrFolderNameMissing
}
cmd := &dashboards.GetDashboardQuery{Slug: slugify.Slugify(folderName), OrgID: cfg.OrgID}
cmd := &dashboards.GetDashboardQuery{
Title: &folderName,
FolderID: util.Pointer(int64(0)),
OrgID: cfg.OrgID,
}
result, err := fr.dashboardStore.GetDashboard(ctx, cmd)
if err != nil && !errors.Is(err, dashboards.ErrDashboardNotFound) {