Remove options form service handler initializer (#4895)

Now that optiosn are being broken up a bit more passing a struct of a single type to the service handler initializer doesn't make much sense. Just remove the parameter since it was unused anyway.

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

#### Issues

- #4896

#### Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-12-20 10:49:28 -08:00 committed by GitHub
parent d6db70c239
commit e46119a818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 24 additions and 50 deletions

View File

@ -111,7 +111,7 @@ func generateAndRestoreItems(
Selector: sel, Selector: sel,
} }
handler, err := ctrl.NewServiceHandler(opts, service) handler, err := ctrl.NewServiceHandler(service)
if err != nil { if err != nil {
return nil, clues.Stack(err) return nil, clues.Stack(err)
} }
@ -460,7 +460,7 @@ func generateAndRestoreDriveItems(
Selector: sel, Selector: sel,
} }
handler, err := ctrl.NewServiceHandler(opts, service) handler, err := ctrl.NewServiceHandler(service)
if err != nil { if err != nil {
return nil, clues.Stack(err) return nil, clues.Stack(err)
} }

View File

@ -520,9 +520,7 @@ func (suite *ControllerIntegrationSuite) TestEmptyCollections() {
Selector: test.sel, Selector: test.sel,
} }
handler, err := suite.ctrl.NewServiceHandler( handler, err := suite.ctrl.NewServiceHandler(test.sel.PathService())
control.DefaultOptions(),
test.sel.PathService())
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
deets, _, err := handler.ConsumeRestoreCollections( deets, _, err := handler.ConsumeRestoreCollections(
@ -567,9 +565,7 @@ func runRestore(
Selector: restoreSel, Selector: restoreSel,
} }
handler, err := restoreCtrl.NewServiceHandler( handler, err := restoreCtrl.NewServiceHandler(sci.Service)
control.DefaultOptions(),
sci.Service)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
deets, status, err := handler.ConsumeRestoreCollections( deets, status, err := handler.ConsumeRestoreCollections(
@ -1173,9 +1169,7 @@ func (suite *ControllerIntegrationSuite) TestMultiFolderBackupDifferentNames() {
Selector: restoreSel, Selector: restoreSel,
} }
handler, err := restoreCtrl.NewServiceHandler( handler, err := restoreCtrl.NewServiceHandler(test.service)
control.DefaultOptions(),
test.service)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
deets, status, err := handler.ConsumeRestoreCollections( deets, status, err := handler.ConsumeRestoreCollections(

View File

@ -8,30 +8,28 @@ import (
"github.com/alcionai/corso/src/internal/m365/service/onedrive" "github.com/alcionai/corso/src/internal/m365/service/onedrive"
"github.com/alcionai/corso/src/internal/m365/service/sharepoint" "github.com/alcionai/corso/src/internal/m365/service/sharepoint"
"github.com/alcionai/corso/src/internal/operations/inject" "github.com/alcionai/corso/src/internal/operations/inject"
"github.com/alcionai/corso/src/pkg/control"
"github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/path"
) )
// NewServiceHandler returns an instance of a struct capable of running various // NewServiceHandler returns an instance of a struct capable of running various
// operations for a given service. // operations for a given service.
func (ctrl *Controller) NewServiceHandler( func (ctrl *Controller) NewServiceHandler(
opts control.Options,
service path.ServiceType, service path.ServiceType,
) (inject.ServiceHandler, error) { ) (inject.ServiceHandler, error) {
ctrl.setResourceHandler(service) ctrl.setResourceHandler(service)
switch service { switch service {
case path.OneDriveService: case path.OneDriveService:
return onedrive.NewOneDriveHandler(opts, ctrl.AC, ctrl.resourceHandler), nil return onedrive.NewOneDriveHandler(ctrl.AC, ctrl.resourceHandler), nil
case path.SharePointService: case path.SharePointService:
return sharepoint.NewSharePointHandler(opts, ctrl.AC, ctrl.resourceHandler), nil return sharepoint.NewSharePointHandler(ctrl.AC, ctrl.resourceHandler), nil
case path.GroupsService: case path.GroupsService:
return groups.NewGroupsHandler(opts, ctrl.AC, ctrl.resourceHandler), nil return groups.NewGroupsHandler(ctrl.AC, ctrl.resourceHandler), nil
case path.ExchangeService: case path.ExchangeService:
return exchange.NewExchangeHandler(opts, ctrl.AC, ctrl.resourceHandler), nil return exchange.NewExchangeHandler(ctrl.AC, ctrl.resourceHandler), nil
} }
return nil, clues.New("unrecognized service"). return nil, clues.New("unrecognized service").

View File

@ -23,16 +23,13 @@ import (
var _ inject.ServiceHandler = &exchangeHandler{} var _ inject.ServiceHandler = &exchangeHandler{}
func NewExchangeHandler( func NewExchangeHandler(
opts control.Options,
apiClient api.Client, apiClient api.Client,
resourceClient idname.GetResourceIDAndNamer, resourceClient idname.GetResourceIDAndNamer,
) *exchangeHandler { ) *exchangeHandler {
return &exchangeHandler{ return &exchangeHandler{
baseExchangeHandler: baseExchangeHandler{ baseExchangeHandler: baseExchangeHandler{},
opts: opts, apiClient: apiClient,
}, resourceClient: resourceClient,
apiClient: apiClient,
resourceClient: resourceClient,
} }
} }
@ -42,9 +39,7 @@ func NewExchangeHandler(
// baseExchangeHandler contains logic for tracking data and doing operations // baseExchangeHandler contains logic for tracking data and doing operations
// (e.x. export) that don't require contact with external M356 services. // (e.x. export) that don't require contact with external M356 services.
type baseExchangeHandler struct { type baseExchangeHandler struct{}
opts control.Options
}
func (h *baseExchangeHandler) CacheItemInfo(v details.ItemInfo) {} func (h *baseExchangeHandler) CacheItemInfo(v details.ItemInfo) {}

View File

@ -382,7 +382,7 @@ func (suite *ExportUnitSuite) TestExportRestoreCollections() {
exportCfg := control.ExportConfig{} exportCfg := control.ExportConfig{}
stats := metrics.ExportStats{} stats := metrics.ExportStats{}
ecs, err := NewExchangeHandler(control.DefaultOptions(), api.Client{}, nil). ecs, err := NewExchangeHandler(api.Client{}, nil).
ProduceExportCollections( ProduceExportCollections(
ctx, ctx,
int(version.Backup), int(version.Backup),

View File

@ -25,13 +25,11 @@ import (
var _ inject.ServiceHandler = &groupsHandler{} var _ inject.ServiceHandler = &groupsHandler{}
func NewGroupsHandler( func NewGroupsHandler(
opts control.Options,
apiClient api.Client, apiClient api.Client,
resourceGetter idname.GetResourceIDAndNamer, resourceGetter idname.GetResourceIDAndNamer,
) *groupsHandler { ) *groupsHandler {
return &groupsHandler{ return &groupsHandler{
baseGroupsHandler: baseGroupsHandler{ baseGroupsHandler: baseGroupsHandler{
opts: opts,
backupDriveIDNames: idname.NewCache(nil), backupDriveIDNames: idname.NewCache(nil),
backupSiteIDWebURL: idname.NewCache(nil), backupSiteIDWebURL: idname.NewCache(nil),
}, },
@ -47,8 +45,6 @@ func NewGroupsHandler(
// baseGroupsHandler contains logic for tracking data and doing operations // baseGroupsHandler contains logic for tracking data and doing operations
// (e.x. export) that don't require contact with external M356 services. // (e.x. export) that don't require contact with external M356 services.
type baseGroupsHandler struct { type baseGroupsHandler struct {
opts control.Options
backupDriveIDNames idname.CacheBuilder backupDriveIDNames idname.CacheBuilder
backupSiteIDWebURL idname.CacheBuilder backupSiteIDWebURL idname.CacheBuilder
} }

View File

@ -98,7 +98,7 @@ func (suite *ExportUnitSuite) TestExportRestoreCollections_messages() {
stats := metrics.ExportStats{} stats := metrics.ExportStats{}
ecs, err := NewGroupsHandler(control.DefaultOptions(), api.Client{}, nil). ecs, err := NewGroupsHandler(api.Client{}, nil).
ProduceExportCollections( ProduceExportCollections(
ctx, ctx,
int(version.Backup), int(version.Backup),
@ -198,7 +198,7 @@ func (suite *ExportUnitSuite) TestExportRestoreCollections_libraries() {
}, },
} }
handler := NewGroupsHandler(control.DefaultOptions(), api.Client{}, nil) handler := NewGroupsHandler(api.Client{}, nil)
handler.CacheItemInfo(dii) handler.CacheItemInfo(dii)
stats := metrics.ExportStats{} stats := metrics.ExportStats{}

View File

@ -52,7 +52,7 @@ func (suite *GroupsUnitSuite) TestConsumeRestoreCollections_noErrorOnGroups() {
mock.Collection{Path: pth}, mock.Collection{Path: pth},
} }
_, _, err = NewGroupsHandler(control.DefaultOptions(), api.Client{}, nil). _, _, err = NewGroupsHandler(api.Client{}, nil).
ConsumeRestoreCollections( ConsumeRestoreCollections(
ctx, ctx,
rcc, rcc,

View File

@ -22,13 +22,11 @@ import (
var _ inject.ServiceHandler = &onedriveHandler{} var _ inject.ServiceHandler = &onedriveHandler{}
func NewOneDriveHandler( func NewOneDriveHandler(
opts control.Options,
apiClient api.Client, apiClient api.Client,
resourceGetter idname.GetResourceIDAndNamer, resourceGetter idname.GetResourceIDAndNamer,
) *onedriveHandler { ) *onedriveHandler {
return &onedriveHandler{ return &onedriveHandler{
baseOneDriveHandler: baseOneDriveHandler{ baseOneDriveHandler: baseOneDriveHandler{
opts: opts,
backupDriveIDNames: idname.NewCache(nil), backupDriveIDNames: idname.NewCache(nil),
}, },
apiClient: apiClient, apiClient: apiClient,
@ -43,7 +41,6 @@ func NewOneDriveHandler(
// baseOneDriveHandler contains logic for tracking data and doing operations // baseOneDriveHandler contains logic for tracking data and doing operations
// (e.x. export) that don't require contact with external M356 services. // (e.x. export) that don't require contact with external M356 services.
type baseOneDriveHandler struct { type baseOneDriveHandler struct {
opts control.Options
backupDriveIDNames idname.CacheBuilder backupDriveIDNames idname.CacheBuilder
} }

View File

@ -343,7 +343,7 @@ func (suite *ExportUnitSuite) TestExportRestoreCollections() {
stats := metrics.ExportStats{} stats := metrics.ExportStats{}
ecs, err := NewOneDriveHandler(control.DefaultOptions(), api.Client{}, nil). ecs, err := NewOneDriveHandler(api.Client{}, nil).
ProduceExportCollections( ProduceExportCollections(
ctx, ctx,
int(version.Backup), int(version.Backup),

View File

@ -23,13 +23,11 @@ import (
var _ inject.ServiceHandler = &sharepointHandler{} var _ inject.ServiceHandler = &sharepointHandler{}
func NewSharePointHandler( func NewSharePointHandler(
opts control.Options,
apiClient api.Client, apiClient api.Client,
resourceGetter idname.GetResourceIDAndNamer, resourceGetter idname.GetResourceIDAndNamer,
) *sharepointHandler { ) *sharepointHandler {
return &sharepointHandler{ return &sharepointHandler{
baseSharePointHandler: baseSharePointHandler{ baseSharePointHandler: baseSharePointHandler{
opts: opts,
backupDriveIDNames: idname.NewCache(nil), backupDriveIDNames: idname.NewCache(nil),
}, },
apiClient: apiClient, apiClient: apiClient,
@ -44,7 +42,6 @@ func NewSharePointHandler(
// baseSharePointHandler contains logic for tracking data and doing operations // baseSharePointHandler contains logic for tracking data and doing operations
// (e.x. export) that don't require contact with external M356 services. // (e.x. export) that don't require contact with external M356 services.
type baseSharePointHandler struct { type baseSharePointHandler struct {
opts control.Options
backupDriveIDNames idname.CacheBuilder backupDriveIDNames idname.CacheBuilder
} }

View File

@ -127,7 +127,7 @@ func (suite *ExportUnitSuite) TestExportRestoreCollections() {
}, },
} }
handler := NewSharePointHandler(control.DefaultOptions(), api.Client{}, nil) handler := NewSharePointHandler(api.Client{}, nil)
handler.CacheItemInfo(test.itemInfo) handler.CacheItemInfo(test.itemInfo)
stats := metrics.ExportStats{} stats := metrics.ExportStats{}

View File

@ -133,7 +133,6 @@ type (
ToServiceHandler interface { ToServiceHandler interface {
NewServiceHandler( NewServiceHandler(
opts control.Options,
service path.ServiceType, service path.ServiceType,
) (ServiceHandler, error) ) (ServiceHandler, error)
} }

View File

@ -350,9 +350,7 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoBackup() {
count.New()) count.New())
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
rc, err := ctrl.NewServiceHandler( rc, err := ctrl.NewServiceHandler(rsel.PathService())
control.DefaultOptions(),
rsel.PathService())
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
ro, err := NewRestoreOperation( ro, err := NewRestoreOperation(

View File

@ -590,7 +590,7 @@ func generateContainerOfItems(
Selector: sel, Selector: sel,
} }
handler, err := ctrl.NewServiceHandler(opts, service) handler, err := ctrl.NewServiceHandler(service)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
deets, _, err := handler.ConsumeRestoreCollections( deets, _, err := handler.ConsumeRestoreCollections(

View File

@ -151,7 +151,7 @@ func newTestRestoreOp(
) operations.RestoreOperation { ) operations.RestoreOperation {
rod.ctrl.IDNameLookup = idname.NewCache(map[string]string{rod.sel.ID(): rod.sel.Name()}) rod.ctrl.IDNameLookup = idname.NewCache(map[string]string{rod.sel.ID(): rod.sel.Name()})
handler, err := rod.ctrl.NewServiceHandler(opts, rod.sel.PathService()) handler, err := rod.ctrl.NewServiceHandler(rod.sel.PathService())
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
ro, err := operations.NewRestoreOperation( ro, err := operations.NewRestoreOperation(

View File

@ -28,7 +28,7 @@ func (r repository) NewExport(
sel selectors.Selector, sel selectors.Selector,
exportCfg control.ExportConfig, exportCfg control.ExportConfig,
) (operations.ExportOperation, error) { ) (operations.ExportOperation, error) {
handler, err := r.Provider.NewServiceHandler(r.Opts, sel.PathService()) handler, err := r.Provider.NewServiceHandler(sel.PathService())
if err != nil { if err != nil {
return operations.ExportOperation{}, clues.Stack(err) return operations.ExportOperation{}, clues.Stack(err)
} }

View File

@ -29,7 +29,7 @@ func (r repository) NewRestore(
sel selectors.Selector, sel selectors.Selector,
restoreCfg control.RestoreConfig, restoreCfg control.RestoreConfig,
) (operations.RestoreOperation, error) { ) (operations.RestoreOperation, error) {
handler, err := r.Provider.NewServiceHandler(r.Opts, sel.PathService()) handler, err := r.Provider.NewServiceHandler(sel.PathService())
if err != nil { if err != nil {
return operations.RestoreOperation{}, clues.Stack(err) return operations.RestoreOperation{}, clues.Stack(err)
} }