feat: [CDE-192]: modularize gitspace services (#2396)

* feat: [CDE-192]: modularize gitspace services
* feat: [CDE-192]: modularize gitspace services
pull/3545/head v1.0.4-gitspaces-beta
Ansuman Satapathy 2024-08-05 10:00:48 +00:00 committed by Harness
parent 34a07f4d8b
commit 6338af6336
3 changed files with 47 additions and 55 deletions

View File

@ -63,30 +63,28 @@ func (s SpaceOutput) MarshalJSON() ([]byte, error) {
type Controller struct {
nestedSpacesEnabled bool
tx dbtx.Transactor
urlProvider url.Provider
sseStreamer sse.Streamer
identifierCheck check.SpaceIdentifier
authorizer authz.Authorizer
spacePathStore store.SpacePathStore
pipelineStore store.PipelineStore
secretStore store.SecretStore
connectorStore store.ConnectorStore
templateStore store.TemplateStore
spaceStore store.SpaceStore
repoStore store.RepoStore
principalStore store.PrincipalStore
repoCtrl *repo.Controller
membershipStore store.MembershipStore
importer *importer.Repository
exporter *exporter.Repository
resourceLimiter limiter.ResourceLimiter
publicAccess publicaccess.Service
auditService audit.Service
gitspaceSvc *gitspace.Service
gitspaceConfigStore store.GitspaceConfigStore
gitspaceInstanceStore store.GitspaceInstanceStore
labelSvc *label.Service
tx dbtx.Transactor
urlProvider url.Provider
sseStreamer sse.Streamer
identifierCheck check.SpaceIdentifier
authorizer authz.Authorizer
spacePathStore store.SpacePathStore
pipelineStore store.PipelineStore
secretStore store.SecretStore
connectorStore store.ConnectorStore
templateStore store.TemplateStore
spaceStore store.SpaceStore
repoStore store.RepoStore
principalStore store.PrincipalStore
repoCtrl *repo.Controller
membershipStore store.MembershipStore
importer *importer.Repository
exporter *exporter.Repository
resourceLimiter limiter.ResourceLimiter
publicAccess publicaccess.Service
auditService audit.Service
gitspaceSvc *gitspace.Service
labelSvc *label.Service
}
func NewController(config *types.Config, tx dbtx.Transactor, urlProvider url.Provider,
@ -96,35 +94,31 @@ func NewController(config *types.Config, tx dbtx.Transactor, urlProvider url.Pro
repoStore store.RepoStore, principalStore store.PrincipalStore, repoCtrl *repo.Controller,
membershipStore store.MembershipStore, importer *importer.Repository, exporter *exporter.Repository,
limiter limiter.ResourceLimiter, publicAccess publicaccess.Service, auditService audit.Service,
gitspaceSvc *gitspace.Service,
gitspaceStore store.GitspaceConfigStore, gitspaceInstanceStore store.GitspaceInstanceStore,
labelSvc *label.Service,
gitspaceSvc *gitspace.Service, labelSvc *label.Service,
) *Controller {
return &Controller{
nestedSpacesEnabled: config.NestedSpacesEnabled,
tx: tx,
urlProvider: urlProvider,
sseStreamer: sseStreamer,
identifierCheck: identifierCheck,
authorizer: authorizer,
spacePathStore: spacePathStore,
pipelineStore: pipelineStore,
secretStore: secretStore,
connectorStore: connectorStore,
templateStore: templateStore,
spaceStore: spaceStore,
repoStore: repoStore,
principalStore: principalStore,
repoCtrl: repoCtrl,
membershipStore: membershipStore,
importer: importer,
exporter: exporter,
resourceLimiter: limiter,
publicAccess: publicAccess,
auditService: auditService,
gitspaceSvc: gitspaceSvc,
gitspaceConfigStore: gitspaceStore,
gitspaceInstanceStore: gitspaceInstanceStore,
labelSvc: labelSvc,
nestedSpacesEnabled: config.NestedSpacesEnabled,
tx: tx,
urlProvider: urlProvider,
sseStreamer: sseStreamer,
identifierCheck: identifierCheck,
authorizer: authorizer,
spacePathStore: spacePathStore,
pipelineStore: pipelineStore,
secretStore: secretStore,
connectorStore: connectorStore,
templateStore: templateStore,
spaceStore: spaceStore,
repoStore: repoStore,
principalStore: principalStore,
repoCtrl: repoCtrl,
membershipStore: membershipStore,
importer: importer,
exporter: exporter,
resourceLimiter: limiter,
publicAccess: publicAccess,
auditService: auditService,
gitspaceSvc: gitspaceSvc,
labelSvc: labelSvc,
}
}

View File

@ -47,7 +47,6 @@ func ProvideController(config *types.Config, tx dbtx.Transactor, urlProvider url
repoCtrl *repo.Controller, membershipStore store.MembershipStore, importer *importer.Repository,
exporter *exporter.Repository, limiter limiter.ResourceLimiter, publicAccess publicaccess.Service,
auditService audit.Service, gitspaceService *gitspace.Service,
gitspaceConfigStore store.GitspaceConfigStore, instanceStore store.GitspaceInstanceStore,
labelSvc *label.Service,
) *Controller {
return NewController(config, tx, urlProvider, sseStreamer, identifierCheck, authorizer,
@ -57,6 +56,5 @@ func ProvideController(config *types.Config, tx dbtx.Transactor, urlProvider url
repoCtrl, membershipStore, importer,
exporter, limiter, publicAccess,
auditService, gitspaceService,
gitspaceConfigStore, instanceStore,
labelSvc)
}

View File

@ -269,7 +269,7 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
factory := infraprovider.ProvideFactory(dockerProvider)
infraproviderService := infraprovider2.ProvideInfraProvider(transactor, infraProviderResourceStore, infraProviderConfigStore, factory, spaceStore)
gitspaceService := gitspace.ProvideGitspace(transactor, gitspaceConfigStore, gitspaceInstanceStore, spaceStore, infraproviderService)
spaceController := space.ProvideController(config, transactor, provider, streamer, spaceIdentifier, authorizer, spacePathStore, pipelineStore, secretStore, connectorStore, templateStore, spaceStore, repoStore, principalStore, repoController, membershipStore, repository, exporterRepository, resourceLimiter, publicaccessService, auditService, gitspaceService, gitspaceConfigStore, gitspaceInstanceStore, labelService)
spaceController := space.ProvideController(config, transactor, provider, streamer, spaceIdentifier, authorizer, spacePathStore, pipelineStore, secretStore, connectorStore, templateStore, spaceStore, repoStore, principalStore, repoController, membershipStore, repository, exporterRepository, resourceLimiter, publicaccessService, auditService, gitspaceService, labelService)
pipelineController := pipeline.ProvideController(repoStore, triggerStore, authorizer, pipelineStore)
secretController := secret.ProvideController(encrypter, secretStore, authorizer, spaceStore)
triggerController := trigger.ProvideController(authorizer, triggerStore, pipelineStore, repoStore)