From bb27b8e44d835b96ecf36ffa1f087db2ec168626 Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:08:14 -0800 Subject: [PATCH] Rename service handlers (#4571) Rename these handlers to be baseHandler so that we get some segmentation of functionality. This will allow us a bit of compile-time safety when it comes to accessing graph because the base handler doesn't contain a client instance. Essentially it allows us local access to things for operations like restore. Future additions to the handler that require a client should wrap this base handler to provide that functionality. Export functions shouldn't be updated to be part of the new handler wrapper but should stay as part of the base handler so they continue to not have access to graph. --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [x] :broom: Tech Debt/Cleanup #### Issue(s) * #4254 #### Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- src/internal/m365/service/groups/export.go | 12 ++++++------ src/internal/m365/service/onedrive/export.go | 12 ++++++------ src/internal/m365/service/sharepoint/export.go | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/internal/m365/service/groups/export.go b/src/internal/m365/service/groups/export.go index 82ee4548a..61b2546c8 100644 --- a/src/internal/m365/service/groups/export.go +++ b/src/internal/m365/service/groups/export.go @@ -19,26 +19,26 @@ import ( "github.com/alcionai/corso/src/pkg/path" ) -var _ inject.ServiceHandler = &groupsHandler{} +var _ inject.ServiceHandler = &baseGroupsHandler{} func NewGroupsHandler( opts control.Options, -) *groupsHandler { - return &groupsHandler{ +) *baseGroupsHandler { + return &baseGroupsHandler{ opts: opts, backupDriveIDNames: idname.NewCache(nil), backupSiteIDWebURL: idname.NewCache(nil), } } -type groupsHandler struct { +type baseGroupsHandler struct { opts control.Options backupDriveIDNames idname.CacheBuilder backupSiteIDWebURL idname.CacheBuilder } -func (h *groupsHandler) CacheItemInfo(v details.ItemInfo) { +func (h *baseGroupsHandler) CacheItemInfo(v details.ItemInfo) { if v.Groups == nil { return } @@ -49,7 +49,7 @@ func (h *groupsHandler) CacheItemInfo(v details.ItemInfo) { // ProduceExportCollections will create the export collections for the // given restore collections. -func (h *groupsHandler) ProduceExportCollections( +func (h *baseGroupsHandler) ProduceExportCollections( ctx context.Context, backupVersion int, exportCfg control.ExportConfig, diff --git a/src/internal/m365/service/onedrive/export.go b/src/internal/m365/service/onedrive/export.go index 93a268644..b1945cd3e 100644 --- a/src/internal/m365/service/onedrive/export.go +++ b/src/internal/m365/service/onedrive/export.go @@ -15,25 +15,25 @@ import ( "github.com/alcionai/corso/src/pkg/path" ) -var _ inject.ServiceHandler = &onedriveHandler{} +var _ inject.ServiceHandler = &baseOnedriveHandler{} func NewOneDriveHandler( opts control.Options, -) *onedriveHandler { - return &onedriveHandler{ +) *baseOnedriveHandler { + return &baseOnedriveHandler{ opts: opts, } } -type onedriveHandler struct { +type baseOnedriveHandler struct { opts control.Options } -func (h *onedriveHandler) CacheItemInfo(v details.ItemInfo) {} +func (h *baseOnedriveHandler) CacheItemInfo(v details.ItemInfo) {} // ProduceExportCollections will create the export collections for the // given restore collections. -func (h *onedriveHandler) ProduceExportCollections( +func (h *baseOnedriveHandler) ProduceExportCollections( ctx context.Context, backupVersion int, exportCfg control.ExportConfig, diff --git a/src/internal/m365/service/sharepoint/export.go b/src/internal/m365/service/sharepoint/export.go index 461c6256c..c185b6d05 100644 --- a/src/internal/m365/service/sharepoint/export.go +++ b/src/internal/m365/service/sharepoint/export.go @@ -17,23 +17,23 @@ import ( "github.com/alcionai/corso/src/pkg/path" ) -var _ inject.ServiceHandler = &sharepointHandler{} +var _ inject.ServiceHandler = &baseSharepointHandler{} func NewSharePointHandler( opts control.Options, -) *sharepointHandler { - return &sharepointHandler{ +) *baseSharepointHandler { + return &baseSharepointHandler{ opts: opts, backupDriveIDNames: idname.NewCache(nil), } } -type sharepointHandler struct { +type baseSharepointHandler struct { opts control.Options backupDriveIDNames idname.CacheBuilder } -func (h *sharepointHandler) CacheItemInfo(v details.ItemInfo) { +func (h *baseSharepointHandler) CacheItemInfo(v details.ItemInfo) { // Old versions would store SharePoint data as OneDrive. switch { case v.SharePoint != nil: @@ -46,7 +46,7 @@ func (h *sharepointHandler) CacheItemInfo(v details.ItemInfo) { // ProduceExportCollections will create the export collections for the // given restore collections. -func (h *sharepointHandler) ProduceExportCollections( +func (h *baseSharepointHandler) ProduceExportCollections( ctx context.Context, backupVersion int, exportCfg control.ExportConfig,