Chore: Deprecate folderID from dashboardIdentity (#77650)

This commit is contained in:
Kat Yang 2023-11-09 10:57:33 -05:00 committed by GitHub
parent 4e57324d58
commit 1c758ab5f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View File

@ -243,6 +243,7 @@ func (fr *FileReader) saveDashboard(ctx context.Context, path string, folderID i
// keeps track of which UIDs and titles we have already provisioned
dash := jsonFile.dashboard
provisioningMetadata.uid = dash.Dashboard.UID
// nolint:staticcheck
provisioningMetadata.identity = dashboardIdentity{title: dash.Dashboard.Title, folderID: dash.Dashboard.FolderID}
// fix empty folder_uid from already provisioned dashboards
@ -480,6 +481,7 @@ type provisioningMetadata struct {
}
type dashboardIdentity struct {
// Deprecated: use FolderUID instead
folderID int64
title string
}

View File

@ -102,6 +102,7 @@ func (c *duplicateValidator) logWarnings(duplicatesByOrg map[int64]duplicateEntr
for id, usage := range duplicates.Titles {
if usage.Sum > 1 {
// nolint:staticcheck
c.logger.Warn("dashboard title is not unique in folder", "orgId", orgID, "title", id.title, "folderID", id.folderID, "times",
usage.Sum, "providers", keysToSlice(usage.InvolvedReaders))
}

View File

@ -42,6 +42,7 @@ func TestDuplicatesValidator(t *testing.T) {
folderID, _, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, folderName)
require.NoError(t, err)
// nolint:staticcheck
identity := dashboardIdentity{folderID: folderID, title: "Grafana"}
cfg1 := &config{
@ -95,6 +96,7 @@ func TestDuplicatesValidator(t *testing.T) {
folderID, _, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, folderName)
require.NoError(t, err)
// nolint:staticcheck
identity := dashboardIdentity{folderID: folderID, title: "Grafana"}
cfg1 := &config{
@ -197,6 +199,7 @@ func TestDuplicatesValidator(t *testing.T) {
folderID, _, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, cfg1.Folder)
require.NoError(t, err)
// nolint:staticcheck
identity := dashboardIdentity{folderID: folderID, title: "Grafana"}
require.Equal(t, uint8(2), duplicates[1].UIDs["Z-phNqGmz"].Sum)
@ -214,6 +217,7 @@ func TestDuplicatesValidator(t *testing.T) {
folderID, _, err = r.getOrCreateFolder(context.Background(), cfg3, fakeService, cfg3.Folder)
require.NoError(t, err)
// nolint:staticcheck
identity = dashboardIdentity{folderID: folderID, title: "Grafana"}
require.Equal(t, uint8(2), duplicates[2].UIDs["Z-phNqGmz"].Sum)