From e15e2ee5169a03d151a1b1968999cd99cbad3fbd Mon Sep 17 00:00:00 2001 From: Sandeep Bhardwaj Date: Fri, 3 Mar 2023 19:33:04 +0530 Subject: [PATCH] refactor: make resource create backward compatible --- core/resource/service/resource_manager.go | 2 +- .../resource/service/resource_manager_test.go | 2 +- core/resource/service/resource_service.go | 26 ++- .../resource/service/resource_service_test.go | 155 +++++++----------- server/optimus.go | 2 +- 5 files changed, 76 insertions(+), 111 deletions(-) diff --git a/core/resource/service/resource_manager.go b/core/resource/service/resource_manager.go index 06e52266f9..fc7cadef4d 100644 --- a/core/resource/service/resource_manager.go +++ b/core/resource/service/resource_manager.go @@ -48,8 +48,8 @@ func (m *ResourceMgr) CreateResource(ctx context.Context, res *resource.Resource me.Append(res.MarkExistInStore()) } else { me.Append(res.MarkFailure()) + me.Append(err) } - me.Append(err) } else { me.Append(res.MarkSuccess()) } diff --git a/core/resource/service/resource_manager_test.go b/core/resource/service/resource_manager_test.go index be3f8b563b..bea91aa060 100644 --- a/core/resource/service/resource_manager_test.go +++ b/core/resource/service/resource_manager_test.go @@ -115,7 +115,7 @@ func TestResourceManager(t *testing.T) { manager.RegisterDatastore(store, storeService) err = manager.CreateResource(ctx, createRequest) - assert.Error(t, err) + assert.NoError(t, err) }) t.Run("creates the resource on the datastore", func(t *testing.T) { spec := map[string]any{"description": "test spec"} diff --git a/core/resource/service/resource_service.go b/core/resource/service/resource_service.go index 23584329d9..0dc6ac87a8 100644 --- a/core/resource/service/resource_service.go +++ b/core/resource/service/resource_service.go @@ -26,24 +26,18 @@ type ResourceManager interface { GetURN(res *resource.Resource) (string, error) } -type TenantDetailsGetter interface { - GetDetails(ctx context.Context, tnnt tenant.Tenant) (*tenant.WithDetails, error) -} - type ResourceService struct { - repo ResourceRepository - mgr ResourceManager - tnntDetailsGetter TenantDetailsGetter + repo ResourceRepository + mgr ResourceManager logger log.Logger } -func NewResourceService(logger log.Logger, repo ResourceRepository, mgr ResourceManager, tnntDetailsGetter TenantDetailsGetter) *ResourceService { +func NewResourceService(logger log.Logger, repo ResourceRepository, mgr ResourceManager) *ResourceService { return &ResourceService{ - repo: repo, - mgr: mgr, - tnntDetailsGetter: tnntDetailsGetter, - logger: logger, + repo: repo, + mgr: mgr, + logger: logger, } } @@ -70,10 +64,6 @@ func (rs ResourceService) Create(ctx context.Context, incoming *resource.Resourc return err } - if _, err := rs.tnntDetailsGetter.GetDetails(ctx, incoming.Tenant()); err != nil { - rs.logger.Error("error getting tenant for resource [%s] details: %s", incoming.FullName(), err) - return err - } incoming.MarkToCreate() if err := rs.repo.Create(ctx, incoming); err != nil { @@ -81,6 +71,10 @@ func (rs ResourceService) Create(ctx context.Context, incoming *resource.Resourc return err } } else { + if existing.Status() == resource.StatusSuccess || existing.Status() == resource.StatusExistInStore { + return nil // Note: return in case resource already exists + } + if !resource.StatusForToCreate(existing.Status()) { msg := fmt.Sprintf("cannot create resource [%s] since it already exists with status [%s]", incoming.FullName(), existing.Status()) rs.logger.Error(msg) diff --git a/core/resource/service/resource_service_test.go b/core/resource/service/resource_service_test.go index f1475dfdc4..665f2c7cb8 100644 --- a/core/resource/service/resource_service_test.go +++ b/core/resource/service/resource_service_test.go @@ -36,7 +36,7 @@ func TestResourceService(t *testing.T) { mgr := newResourceManager(t) mgr.On("Validate", invalid).Return(errors.New("validation error")) - rscService := service.NewResourceService(logger, nil, mgr, nil) + rscService := service.NewResourceService(logger, nil, mgr) actualError := rscService.Create(ctx, invalid) assert.Error(t, actualError) @@ -50,7 +50,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", incoming).Return(nil) mgr.On("GetURN", incoming).Return("", errors.New("urn error")) - rscService := service.NewResourceService(logger, nil, mgr, nil) + rscService := service.NewResourceService(logger, nil, mgr) actualError := rscService.Create(ctx, incoming) assert.Error(t, actualError) @@ -67,7 +67,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", incoming).Return(nil) mgr.On("GetURN", incoming).Return(urn, nil) - rscService := service.NewResourceService(logger, nil, mgr, nil) + rscService := service.NewResourceService(logger, nil, mgr) actualError := rscService.Create(ctx, incoming) assert.Error(t, actualError) @@ -85,33 +85,13 @@ func TestResourceService(t *testing.T) { repo := newResourceRepository(t) repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, incoming.FullName()).Return(nil, errors.New("unknown error")) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Create(ctx, incoming) assert.ErrorContains(t, actualError, "unknown error") }) t.Run("resource does not exist in repository", func(t *testing.T) { - t.Run("returns error if error is encountered when getting tenant for the resource", func(t *testing.T) { - incoming, err := resource.NewResource("project.dataset", "dataset", resource.Bigquery, tnnt, meta, spec) - assert.NoError(t, err) - - mgr := newResourceManager(t) - mgr.On("Validate", incoming).Return(nil) - mgr.On("GetURN", incoming).Return("bigquery://project:dataset", nil) - - repo := newResourceRepository(t) - repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, incoming.FullName()).Return(nil, oErrors.NotFound(resource.EntityResource, "resource not found")) - - tnntDetailsGetter := newTenantDetailsGetter(t) - tnntDetailsGetter.On("GetDetails", ctx, tnnt).Return(nil, errors.New("error getting tenant")) - - rscService := service.NewResourceService(logger, repo, mgr, tnntDetailsGetter) - - actualError := rscService.Create(ctx, incoming) - assert.ErrorContains(t, actualError, "error getting tenant") - }) - t.Run("returns error if error is encountered when creating resource to repository", func(t *testing.T) { incoming, err := resource.NewResource("project.dataset", "dataset", resource.Bigquery, tnnt, meta, spec) assert.NoError(t, err) @@ -120,14 +100,11 @@ func TestResourceService(t *testing.T) { repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, incoming.FullName()).Return(nil, oErrors.NotFound(resource.EntityResource, "resource not found")) repo.On("Create", ctx, mock.Anything).Return(errors.New("error creating resource")) - tnntDetailsGetter := newTenantDetailsGetter(t) - tnntDetailsGetter.On("GetDetails", ctx, tnnt).Return(nil, nil) - mgr := newResourceManager(t) mgr.On("Validate", incoming).Return(nil) mgr.On("GetURN", incoming).Return("bigquery://project:dataset", nil) - rscService := service.NewResourceService(logger, repo, mgr, tnntDetailsGetter) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Create(ctx, incoming) assert.ErrorContains(t, actualError, "error creating resource") @@ -135,7 +112,7 @@ func TestResourceService(t *testing.T) { }) t.Run("resource already exists in repository", func(t *testing.T) { - t.Run("returns error if status is neither create_failure nor to_create", func(t *testing.T) { + t.Run("returns no error if status is success or exists_in_store", func(t *testing.T) { existing, err := resource.NewResource("project.dataset", "dataset", resource.Bigquery, tnnt, meta, spec) assert.NoError(t, err) @@ -143,8 +120,34 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", mock.Anything).Return(nil) mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset", nil) - repo := newResourceRepository(t) - rscService := service.NewResourceService(logger, repo, mgr, nil) + statusToTest := []resource.Status{ + resource.StatusExistInStore, + resource.StatusSuccess, + } + + for _, status := range statusToTest { + incoming, err := resource.NewResource("project.dataset", "dataset", resource.Bigquery, tnnt, meta, spec) + assert.NoError(t, err) + + existingWithStatus := resource.FromExisting(existing, resource.ReplaceStatus(status)) + + repo := newResourceRepository(t) + repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, incoming.FullName()).Return(existingWithStatus, nil) + + rscService := service.NewResourceService(logger, repo, mgr) + + err = rscService.Create(ctx, incoming) + assert.NoError(t, err) + repo.AssertExpectations(t) + } + }) + t.Run("returns error if status is neither create_failure nor to_create", func(t *testing.T) { + existing, err := resource.NewResource("project.dataset", "dataset", resource.Bigquery, tnnt, meta, spec) + assert.NoError(t, err) + + mgr := newResourceManager(t) + mgr.On("Validate", mock.Anything).Return(nil) + mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset", nil) unacceptableStatuses := []resource.Status{ resource.StatusUnknown, @@ -153,8 +156,6 @@ func TestResourceService(t *testing.T) { resource.StatusToUpdate, resource.StatusSkipped, resource.StatusUpdateFailure, - resource.StatusExistInStore, - resource.StatusSuccess, } for _, status := range unacceptableStatuses { @@ -163,8 +164,10 @@ func TestResourceService(t *testing.T) { existingWithStatus := resource.FromExisting(existing, resource.ReplaceStatus(status)) - repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, incoming.FullName()).Return(existingWithStatus, nil) + repo := newResourceRepository(t) + rscService := service.NewResourceService(logger, repo, mgr) + repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, incoming.FullName()).Return(existingWithStatus, nil) actualError := rscService.Create(ctx, incoming) assert.ErrorContains(t, actualError, "since it already exists with status") repo.AssertExpectations(t) @@ -186,7 +189,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", incoming).Return(nil) mgr.On("GetURN", incoming).Return("bigquery://project:dataset", nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Create(ctx, incoming) assert.ErrorContains(t, actualError, "error updating resource") @@ -206,10 +209,7 @@ func TestResourceService(t *testing.T) { mgr.On("GetURN", incoming).Return("bigquery://project:dataset", nil) mgr.On("CreateResource", ctx, incoming).Return(errors.New("error creating to store")) - tnntDetailsGetter := newTenantDetailsGetter(t) - tnntDetailsGetter.On("GetDetails", ctx, tnnt).Return(nil, nil) - - rscService := service.NewResourceService(logger, repo, mgr, tnntDetailsGetter) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Create(ctx, incoming) assert.ErrorContains(t, actualError, "error creating to store") @@ -223,15 +223,12 @@ func TestResourceService(t *testing.T) { repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, incoming.FullName()).Return(nil, oErrors.NotFound(resource.EntityResource, "resource not found")) repo.On("Create", ctx, incoming).Return(nil) - tnntDetailsGetter := newTenantDetailsGetter(t) - tnntDetailsGetter.On("GetDetails", ctx, tnnt).Return(nil, nil) - mgr := newResourceManager(t) mgr.On("Validate", incoming).Return(nil) mgr.On("GetURN", incoming).Return("bigquery://project:dataset", nil) mgr.On("CreateResource", ctx, incoming).Return(nil) - rscService := service.NewResourceService(logger, repo, mgr, tnntDetailsGetter) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Create(ctx, incoming) assert.NoError(t, actualError) @@ -245,7 +242,7 @@ func TestResourceService(t *testing.T) { mgr := newResourceManager(t) mgr.On("Validate", invalidResource).Return(errors.New("validation error")) - rscService := service.NewResourceService(logger, nil, mgr, nil) + rscService := service.NewResourceService(logger, nil, mgr) actualError := rscService.Update(ctx, invalidResource) assert.Error(t, actualError) @@ -258,7 +255,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", incoming).Return(nil) mgr.On("GetURN", incoming).Return("", errors.New("urn error")) - rscService := service.NewResourceService(logger, nil, mgr, nil) + rscService := service.NewResourceService(logger, nil, mgr) actualError := rscService.Update(ctx, incoming) assert.Error(t, actualError) @@ -275,7 +272,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", incoming).Return(nil) mgr.On("GetURN", incoming).Return(urn, nil) - rscService := service.NewResourceService(logger, nil, mgr, nil) + rscService := service.NewResourceService(logger, nil, mgr) actualError := rscService.Update(ctx, incoming) assert.Error(t, actualError) @@ -294,7 +291,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", resourceToUpdate).Return(nil) mgr.On("GetURN", resourceToUpdate).Return("bigquery://project:dataset", nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Update(ctx, resourceToUpdate) assert.ErrorContains(t, actualError, "unknown error") @@ -309,7 +306,7 @@ func TestResourceService(t *testing.T) { mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset", nil) repo := newResourceRepository(t) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) unacceptableStatuses := []resource.Status{ resource.StatusUnknown, @@ -349,7 +346,7 @@ func TestResourceService(t *testing.T) { repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, fullName).Return(existingResource, nil) repo.On("Update", ctx, mock.Anything).Return(errors.New("unknown error")) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Update(ctx, resourceToUpdate) assert.ErrorContains(t, actualError, "unknown error") @@ -372,7 +369,7 @@ func TestResourceService(t *testing.T) { mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset", nil) mgr.On("UpdateResource", ctx, mock.Anything).Return(errors.New("unknown error")) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Update(ctx, resourceToUpdate) assert.ErrorContains(t, actualError, "unknown error") @@ -395,7 +392,7 @@ func TestResourceService(t *testing.T) { mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset", nil) mgr.On("UpdateResource", ctx, mock.Anything).Return(nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Update(ctx, resourceToUpdate) assert.NoError(t, actualError) @@ -404,7 +401,7 @@ func TestResourceService(t *testing.T) { t.Run("Get", func(t *testing.T) { t.Run("returns nil and error if resource name is empty", func(t *testing.T) { - rscService := service.NewResourceService(logger, nil, nil, nil) + rscService := service.NewResourceService(logger, nil, nil) store := resource.Bigquery actualResource, actualError := rscService.Get(ctx, tnnt, store, "") @@ -417,7 +414,7 @@ func TestResourceService(t *testing.T) { fullName := "project.dataset" repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, fullName).Return(nil, errors.New("unknown error")) - rscService := service.NewResourceService(logger, repo, nil, nil) + rscService := service.NewResourceService(logger, repo, nil) actualResource, actualError := rscService.Get(ctx, tnnt, resource.Bigquery, fullName) assert.Nil(t, actualResource) @@ -432,7 +429,7 @@ func TestResourceService(t *testing.T) { repo := newResourceRepository(t) repo.On("ReadByFullName", ctx, tnnt, resource.Bigquery, fullName).Return(existingResource, nil) - rscService := service.NewResourceService(logger, repo, nil, nil) + rscService := service.NewResourceService(logger, repo, nil) actualResource, actualError := rscService.Get(ctx, tnnt, resource.Bigquery, fullName) assert.EqualValues(t, existingResource, actualResource) @@ -445,7 +442,7 @@ func TestResourceService(t *testing.T) { repo := newResourceRepository(t) repo.On("ReadAll", ctx, tnnt, resource.Bigquery).Return(nil, errors.New("unknown error")) - rscService := service.NewResourceService(logger, repo, nil, nil) + rscService := service.NewResourceService(logger, repo, nil) actualResources, actualError := rscService.GetAll(ctx, tnnt, resource.Bigquery) assert.Nil(t, actualResources) @@ -459,7 +456,7 @@ func TestResourceService(t *testing.T) { repo := newResourceRepository(t) repo.On("ReadAll", ctx, tnnt, resource.Bigquery).Return([]*resource.Resource{existingResource}, nil) - rscService := service.NewResourceService(logger, repo, nil, nil) + rscService := service.NewResourceService(logger, repo, nil) actualResources, actualError := rscService.GetAll(ctx, tnnt, resource.Bigquery) assert.EqualValues(t, []*resource.Resource{existingResource}, actualResources) @@ -487,7 +484,7 @@ func TestResourceService(t *testing.T) { mgr := newResourceManager(t) mgr.On("Validate", invalidResourceToUpdate).Return(errors.New("error validating")) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, resourcesToUpdate) assert.Error(t, actualError) @@ -505,7 +502,7 @@ func TestResourceService(t *testing.T) { repo := newResourceRepository(t) repo.On("ReadAll", ctx, tnnt, resource.Bigquery).Return([]*resource.Resource{}, nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, []*resource.Resource{incoming}) assert.Error(t, actualError) @@ -527,7 +524,7 @@ func TestResourceService(t *testing.T) { repo := newResourceRepository(t) repo.On("ReadAll", ctx, tnnt, resource.Bigquery).Return([]*resource.Resource{}, nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, []*resource.Resource{incoming}) assert.Error(t, actualError) @@ -546,7 +543,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", incomingResourceToUpdate).Return(nil) mgr.On("GetURN", incomingResourceToUpdate).Return("bigquery://project:dataset.table1", nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, resourcesToUpdate) assert.ErrorContains(t, actualError, "error while read all") @@ -564,7 +561,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", mock.Anything).Return(nil) mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset.view1", nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, []*resource.Resource{incomingResourceToUpdate}) assert.NoError(t, actualError) @@ -586,7 +583,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", mock.Anything).Return(nil) mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset", nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, []*resource.Resource{incomingResourceToUpdate}) @@ -611,7 +608,7 @@ func TestResourceService(t *testing.T) { mgr.On("Validate", mock.Anything).Return(nil) mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset.view1", nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, []*resource.Resource{incomingResourceToUpdate}) @@ -637,7 +634,7 @@ func TestResourceService(t *testing.T) { mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset.view1", nil) mgr.On("BatchUpdate", ctx, resource.Bigquery, mock.Anything).Return(errors.New("unknown error")) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, []*resource.Resource{incomingResourceToUpdate}) assert.ErrorContains(t, actualError, "unknown error") @@ -665,7 +662,7 @@ func TestResourceService(t *testing.T) { mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset.view1", nil) mgr.On("BatchUpdate", ctx, resource.Bigquery, mock.Anything).Return(errors.New("unknown error")) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, []*resource.Resource{incomingResourceToUpdate}) assert.ErrorContains(t, actualError, "unknown error") @@ -699,7 +696,7 @@ func TestResourceService(t *testing.T) { mgr.On("GetURN", mock.Anything).Return("bigquery://project:dataset.view1", nil) mgr.On("BatchUpdate", ctx, resource.Bigquery, []*resource.Resource{incomingToCreate, incomingToUpdate, incomingToCreateExisting}).Return(nil) - rscService := service.NewResourceService(logger, repo, mgr, nil) + rscService := service.NewResourceService(logger, repo, mgr) incomings := []*resource.Resource{incomingToCreate, incomingToSkip, incomingToUpdate, incomingToCreateExisting} actualError := rscService.Deploy(ctx, tnnt, resource.Bigquery, incomings) @@ -788,29 +785,3 @@ func newResourceManager(t mockConstructorTestingTNewResourceManager) *mockResour return mock } - -type mockTenantDetailsGetter struct { - mock.Mock -} - -func (m *mockTenantDetailsGetter) GetDetails(ctx context.Context, tnnt tenant.Tenant) (*tenant.WithDetails, error) { - args := m.Called(ctx, tnnt) - if args.Get(0) == nil { - return nil, args.Error(1) - } - return args.Get(0).(*tenant.WithDetails), args.Error(1) -} - -type mockConstructorTestingTNewTenantDetailsGetter interface { - mock.TestingT - Cleanup(func()) -} - -func newTenantDetailsGetter(t mockConstructorTestingTNewTenantDetailsGetter) *mockTenantDetailsGetter { - mock := &mockTenantDetailsGetter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/optimus.go b/server/optimus.go index a22d3b7f1d..76028317de 100644 --- a/server/optimus.go +++ b/server/optimus.go @@ -241,7 +241,7 @@ func (s *OptimusServer) setupHandlers() error { resourceRepository := resource.NewRepository(s.dbPool) backupRepository := resource.NewBackupRepository(s.dbPool) resourceManager := rService.NewResourceManager(resourceRepository, s.logger) - resourceService := rService.NewResourceService(s.logger, resourceRepository, resourceManager, tenantService) + resourceService := rService.NewResourceService(s.logger, resourceRepository, resourceManager) backupService := rService.NewBackupService(backupRepository, resourceRepository, resourceManager) // Register datastore