From d090dab13892288b76f20e602e7e3d3cf560f540 Mon Sep 17 00:00:00 2001 From: Kat Yang <69819079+yangkb09@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:21:02 -0500 Subject: [PATCH] Chore: Deprecate FolderID from SaveDashboardCommand (#77813) --- pkg/api/dashboard_test.go | 2 +- pkg/services/alerting/store_test.go | 2 +- .../database/database_folder_test.go | 6 ++-- .../database/database_provisioning_test.go | 6 ++-- .../dashboards/database/database_test.go | 8 ++--- pkg/services/dashboards/models_test.go | 1 + .../dashboard_service_integration_test.go | 36 +++++++++---------- .../dashverimpl/store_test.go | 2 +- .../folderimpl/dashboard_folder_store_test.go | 4 +-- .../publicdashboards/api/query_test.go | 2 +- .../database/database_test.go | 2 +- .../publicdashboards/service/service_test.go | 2 +- .../sqlstore/permissions/dashboard_test.go | 4 +-- 13 files changed, 39 insertions(+), 38 deletions(-) diff --git a/pkg/api/dashboard_test.go b/pkg/api/dashboard_test.go index fc41a360cf2..398415119b2 100644 --- a/pkg/api/dashboard_test.go +++ b/pkg/api/dashboard_test.go @@ -406,7 +406,7 @@ func TestDashboardAPIEndpoint(t *testing.T) { "title": "Dash", }), Overwrite: true, - FolderID: folderID, + FolderID: folderID, // nolint:staticcheck FolderUID: folderUID, IsFolder: false, Message: "msg", diff --git a/pkg/services/alerting/store_test.go b/pkg/services/alerting/store_test.go index 34f20ad20de..23745c1ad84 100644 --- a/pkg/services/alerting/store_test.go +++ b/pkg/services/alerting/store_test.go @@ -439,7 +439,7 @@ func insertTestDashboard(t *testing.T, store db.DB, title string, orgId int64, t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, + FolderID: folderId, // nolint:staticcheck FolderUID: folderUID, IsFolder: isFolder, Dashboard: simplejson.NewFromAny(map[string]any{ diff --git a/pkg/services/dashboards/database/database_folder_test.go b/pkg/services/dashboards/database/database_folder_test.go index 4748a241aaf..43017d7c92a 100644 --- a/pkg/services/dashboards/database/database_folder_test.go +++ b/pkg/services/dashboards/database/database_folder_test.go @@ -337,7 +337,7 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) { Dashboard: simplejson.NewFromAny(map[string]any{ "title": dashInParentTitle, }), - FolderID: nestedFolders[0].ID, + FolderID: nestedFolders[0].ID, // nolint:staticcheck FolderUID: nestedFolders[0].UID, } _, err = dashboardWriteStore.SaveDashboard(context.Background(), saveDashboardCmd) @@ -350,7 +350,7 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) { Dashboard: simplejson.NewFromAny(map[string]any{ "title": dashInSubfolderTitle, }), - FolderID: nestedFolders[1].ID, + FolderID: nestedFolders[1].ID, // nolint:staticcheck FolderUID: nestedFolders[1].UID, } _, err = dashboardWriteStore.SaveDashboard(context.Background(), saveDashboardCmd) @@ -440,7 +440,7 @@ func moveDashboard(t *testing.T, dashboardStore dashboards.Store, orgId int64, d cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: newFolderId, + FolderID: newFolderId, // nolint:staticcheck FolderUID: newFolderUID, Dashboard: dashboard, Overwrite: true, diff --git a/pkg/services/dashboards/database/database_provisioning_test.go b/pkg/services/dashboards/database/database_provisioning_test.go index 9093c61b4c9..6578eafa500 100644 --- a/pkg/services/dashboards/database/database_provisioning_test.go +++ b/pkg/services/dashboards/database/database_provisioning_test.go @@ -25,7 +25,7 @@ func TestIntegrationDashboardProvisioningTest(t *testing.T) { folderCmd := dashboards.SaveDashboardCommand{ OrgID: 1, - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", IsFolder: true, Dashboard: simplejson.NewFromAny(map[string]any{ @@ -40,7 +40,7 @@ func TestIntegrationDashboardProvisioningTest(t *testing.T) { saveDashboardCmd := dashboards.SaveDashboardCommand{ OrgID: 1, IsFolder: false, - FolderID: dash.ID, + FolderID: dash.ID, // nolint:staticcheck FolderUID: dash.UID, Dashboard: simplejson.NewFromAny(map[string]any{ "id": nil, @@ -67,7 +67,7 @@ func TestIntegrationDashboardProvisioningTest(t *testing.T) { saveCmd := dashboards.SaveDashboardCommand{ OrgID: 1, IsFolder: false, - FolderID: dash.ID, + FolderID: dash.ID, // nolint:staticcheck FolderUID: dash.UID, Dashboard: simplejson.NewFromAny(map[string]any{ "id": nil, diff --git a/pkg/services/dashboards/database/database_test.go b/pkg/services/dashboards/database/database_test.go index f0db79ba1e7..761fc9f151d 100644 --- a/pkg/services/dashboards/database/database_test.go +++ b/pkg/services/dashboards/database/database_test.go @@ -219,7 +219,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) { "tags": []interface{}{}, }), Overwrite: true, - FolderID: 2, + FolderID: 2, // nolint:staticcheck UserID: 100, } dash, err := dashboardStore.SaveDashboard(context.Background(), cmd) @@ -234,7 +234,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) { "title": "folderId", "tags": []interface{}{}, }), - FolderID: 0, + FolderID: 0, // nolint:staticcheck Overwrite: true, UserID: 100, } @@ -1151,7 +1151,7 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, + FolderID: folderId, // nolint:staticcheck FolderUID: folderUID, IsFolder: isFolder, Dashboard: simplejson.NewFromAny(map[string]interface{}{ @@ -1173,7 +1173,7 @@ func insertTestDashboardForPlugin(t *testing.T, dashboardStore dashboards.Store, t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, + FolderID: folderId, // nolint:staticcheck IsFolder: isFolder, Dashboard: simplejson.NewFromAny(map[string]interface{}{ "id": nil, diff --git a/pkg/services/dashboards/models_test.go b/pkg/services/dashboards/models_test.go index fd49152dfdb..0e6768ce23a 100644 --- a/pkg/services/dashboards/models_test.go +++ b/pkg/services/dashboards/models_test.go @@ -66,6 +66,7 @@ func TestSaveDashboardCommand_GetDashboardModel(t *testing.T) { json := simplejson.New() json.Set("title", "test dash") + // nolint:staticcheck cmd := &SaveDashboardCommand{Dashboard: json, FolderID: 1, FolderUID: "1"} dash := cmd.GetDashboardModel() diff --git a/pkg/services/dashboards/service/dashboard_service_integration_test.go b/pkg/services/dashboards/service/dashboard_service_integration_test.go index be9df62ccd1..bbe8effe7e1 100644 --- a/pkg/services/dashboards/service/dashboard_service_integration_test.go +++ b/pkg/services/dashboards/service/dashboard_service_integration_test.go @@ -128,7 +128,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { Dashboard: simplejson.NewFromAny(map[string]any{ "title": "Dash", }), - FolderID: sc.otherSavedFolder.ID, + FolderID: sc.otherSavedFolder.ID, // nolint:staticcheck FolderUID: sc.otherSavedFolder.UID, UserID: 10000, Overwrite: true, @@ -152,7 +152,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { Dashboard: simplejson.NewFromAny(map[string]any{ "title": sc.savedDashInFolder.Title, }), - FolderID: sc.savedFolder.ID, + FolderID: sc.savedFolder.ID, // nolint:staticcheck FolderUID: sc.savedFolder.UID, UserID: 10000, Overwrite: true, @@ -177,7 +177,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "uid": sc.savedDashInFolder.UID, "title": "New dash", }), - FolderID: sc.savedFolder.ID, + FolderID: sc.savedFolder.ID, // nolint:staticcheck FolderUID: sc.savedFolder.UID, UserID: 10000, Overwrite: true, @@ -252,7 +252,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "id": sc.savedDashInGeneralFolder.ID, "title": "Dash", }), - FolderID: sc.otherSavedFolder.ID, + FolderID: sc.otherSavedFolder.ID, // nolint:staticcheck FolderUID: sc.otherSavedFolder.UID, UserID: 10000, Overwrite: true, @@ -277,7 +277,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "id": sc.savedDashInFolder.ID, "title": "Dash", }), - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", UserID: 10000, Overwrite: true, @@ -302,7 +302,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "uid": sc.savedDashInGeneralFolder.UID, "title": "Dash", }), - FolderID: sc.otherSavedFolder.ID, + FolderID: sc.otherSavedFolder.ID, // nolint:staticcheck FolderUID: sc.otherSavedFolder.UID, UserID: 10000, Overwrite: true, @@ -327,7 +327,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "uid": sc.savedDashInFolder.UID, "title": "Dash", }), - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", UserID: 10000, Overwrite: true, @@ -359,7 +359,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "id": nil, "title": sc.savedDashInFolder.Title, }), - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", Overwrite: shouldOverwrite, } @@ -383,7 +383,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "id": nil, "title": sc.savedDashInGeneralFolder.Title, }), - FolderID: sc.savedFolder.ID, + FolderID: sc.savedFolder.ID, // nolint:staticcheck FolderUID: sc.savedFolder.UID, Overwrite: shouldOverwrite, } @@ -475,7 +475,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { Dashboard: simplejson.NewFromAny(map[string]any{ "title": "Expect error", }), - FolderID: 123412321, + FolderID: 123412321, // nolint:staticcheck FolderUID: "123412321", Overwrite: shouldOverwrite, } @@ -492,7 +492,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "id": sc.savedDashInGeneralFolder.ID, "title": "test dash 23", }), - FolderID: sc.savedFolder.ID, + FolderID: sc.savedFolder.ID, // nolint:staticcheck FolderUID: sc.savedFolder.UID, Overwrite: shouldOverwrite, } @@ -510,7 +510,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "title": "Updated title", "version": sc.savedDashInGeneralFolder.Version, }), - FolderID: sc.savedFolder.ID, + FolderID: sc.savedFolder.ID, // nolint:staticcheck FolderUID: sc.savedFolder.UID, Overwrite: shouldOverwrite, } @@ -534,7 +534,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "uid": sc.savedDashInFolder.UID, "title": "test dash 23", }), - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", Overwrite: shouldOverwrite, } @@ -552,7 +552,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "title": "Updated title", "version": sc.savedDashInFolder.Version, }), - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", Overwrite: shouldOverwrite, } @@ -629,7 +629,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "id": sc.savedDashInGeneralFolder.ID, "title": "Updated title", }), - FolderID: sc.savedFolder.ID, + FolderID: sc.savedFolder.ID, // nolint:staticcheck FolderUID: sc.savedFolder.UID, Overwrite: shouldOverwrite, } @@ -652,7 +652,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) { "uid": sc.savedDashInFolder.UID, "title": "Updated title", }), - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", Overwrite: shouldOverwrite, } @@ -995,7 +995,7 @@ func saveTestDashboard(t *testing.T, title string, orgID, folderID int64, folder cmd := dashboards.SaveDashboardCommand{ OrgID: orgID, - FolderID: folderID, + FolderID: folderID, // nolint:staticcheck FolderUID: folderUID, IsFolder: false, Dashboard: simplejson.NewFromAny(map[string]any{ @@ -1040,7 +1040,7 @@ func saveTestFolder(t *testing.T, title string, orgID int64, sqlStore db.DB) *da t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgID, - FolderID: 0, + FolderID: 0, // nolint:staticcheck FolderUID: "", IsFolder: true, Dashboard: simplejson.NewFromAny(map[string]any{ diff --git a/pkg/services/dashboardversion/dashverimpl/store_test.go b/pkg/services/dashboardversion/dashverimpl/store_test.go index cd7d6c029c8..538e557aeb0 100644 --- a/pkg/services/dashboardversion/dashverimpl/store_test.go +++ b/pkg/services/dashboardversion/dashverimpl/store_test.go @@ -139,7 +139,7 @@ func insertTestDashboard(t *testing.T, sqlStore db.DB, title string, orgId int64 t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, + FolderID: folderId, // nolint:staticcheck FolderUID: folderUID, IsFolder: isFolder, Dashboard: simplejson.NewFromAny(map[string]any{ diff --git a/pkg/services/folder/folderimpl/dashboard_folder_store_test.go b/pkg/services/folder/folderimpl/dashboard_folder_store_test.go index 0f5b0ce9334..536b7cb08d9 100644 --- a/pkg/services/folder/folderimpl/dashboard_folder_store_test.go +++ b/pkg/services/folder/folderimpl/dashboard_folder_store_test.go @@ -101,7 +101,7 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderID, + FolderID: folderID, // nolint:staticcheck FolderUID: folderUID, IsFolder: false, Dashboard: simplejson.NewFromAny(map[string]any{ @@ -122,7 +122,7 @@ func insertTestFolder(t *testing.T, dashboardStore dashboards.Store, title strin t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, + FolderID: folderId, // nolint:staticcheck FolderUID: folderUID, IsFolder: true, Dashboard: simplejson.NewFromAny(map[string]any{ diff --git a/pkg/services/publicdashboards/api/query_test.go b/pkg/services/publicdashboards/api/query_test.go index 21dfd395803..61fec272367 100644 --- a/pkg/services/publicdashboards/api/query_test.go +++ b/pkg/services/publicdashboards/api/query_test.go @@ -291,7 +291,7 @@ func TestIntegrationUnauthenticatedUserCanGetPubdashPanelQueryData(t *testing.T) // Create Dashboard saveDashboardCmd := dashboards.SaveDashboardCommand{ OrgID: 1, - FolderID: 1, + FolderID: 1, // nolint:staticcheck FolderUID: "1", IsFolder: false, Dashboard: simplejson.NewFromAny(map[string]any{ diff --git a/pkg/services/publicdashboards/database/database_test.go b/pkg/services/publicdashboards/database/database_test.go index b20c01bf12b..6e0ae977682 100644 --- a/pkg/services/publicdashboards/database/database_test.go +++ b/pkg/services/publicdashboards/database/database_test.go @@ -873,7 +873,7 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st t.Helper() cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, + FolderID: folderId, // nolint:staticcheck FolderUID: folderUID, IsFolder: isFolder, Dashboard: simplejson.NewFromAny(map[string]any{ diff --git a/pkg/services/publicdashboards/service/service_test.go b/pkg/services/publicdashboards/service/service_test.go index 5f8352f438e..cb3a1a65615 100644 --- a/pkg/services/publicdashboards/service/service_test.go +++ b/pkg/services/publicdashboards/service/service_test.go @@ -1855,7 +1855,7 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, + FolderID: folderId, // nolint:staticcheck FolderUID: folderUID, IsFolder: isFolder, Dashboard: simplejson.NewFromAny(map[string]any{ diff --git a/pkg/services/sqlstore/permissions/dashboard_test.go b/pkg/services/sqlstore/permissions/dashboard_test.go index f800b264e18..3b372254334 100644 --- a/pkg/services/sqlstore/permissions/dashboard_test.go +++ b/pkg/services/sqlstore/permissions/dashboard_test.go @@ -866,7 +866,7 @@ func setupNestedTest(t *testing.T, usr *user.SignedInUser, perms []accesscontrol // create dashboard under parent folder _, err = dashStore.SaveDashboard(context.Background(), dashboards.SaveDashboardCommand{ OrgID: orgID, - FolderID: parent.ID, + FolderID: parent.ID, // nolint:staticcheck FolderUID: parent.UID, Dashboard: simplejson.NewFromAny(map[string]any{ "title": "dashboard under parent folder", @@ -877,7 +877,7 @@ func setupNestedTest(t *testing.T, usr *user.SignedInUser, perms []accesscontrol // create dashboard under subfolder _, err = dashStore.SaveDashboard(context.Background(), dashboards.SaveDashboardCommand{ OrgID: orgID, - FolderID: subfolder.ID, + FolderID: subfolder.ID, // nolint:staticcheck FolderUID: subfolder.UID, Dashboard: simplejson.NewFromAny(map[string]any{ "title": "dashboard under subfolder",