diff --git a/pkg/appClone/AppCloneService.go b/pkg/appClone/AppCloneService.go index aa7aee9aa7..3ea84c6368 100644 --- a/pkg/appClone/AppCloneService.go +++ b/pkg/appClone/AppCloneService.go @@ -53,6 +53,9 @@ type AppCloneServiceImpl struct { pipelineStageService pipeline.PipelineStageService ciTemplateService pipeline.CiTemplateService appRepository app2.AppRepository + ciPipelineRepository pipelineConfig.CiPipelineRepository + pipelineRepository pipelineConfig.PipelineRepository + appWorkflowRepository appWorkflow2.AppWorkflowRepository } func NewAppCloneServiceImpl(logger *zap.SugaredLogger, @@ -65,7 +68,8 @@ func NewAppCloneServiceImpl(logger *zap.SugaredLogger, propertiesConfigService pipeline.PropertiesConfigService, ciTemplateOverrideRepository pipelineConfig.CiTemplateOverrideRepository, pipelineStageService pipeline.PipelineStageService, ciTemplateService pipeline.CiTemplateService, - appRepository app2.AppRepository) *AppCloneServiceImpl { + appRepository app2.AppRepository, ciPipelineRepository pipelineConfig.CiPipelineRepository, + pipelineRepository pipelineConfig.PipelineRepository, appWorkflowRepository appWorkflow2.AppWorkflowRepository) *AppCloneServiceImpl { return &AppCloneServiceImpl{ logger: logger, pipelineBuilder: pipelineBuilder, @@ -78,6 +82,9 @@ func NewAppCloneServiceImpl(logger *zap.SugaredLogger, pipelineStageService: pipelineStageService, ciTemplateService: ciTemplateService, appRepository: appRepository, + ciPipelineRepository: ciPipelineRepository, + pipelineRepository: pipelineRepository, + appWorkflowRepository: appWorkflowRepository, } } @@ -90,6 +97,16 @@ type CloneRequest struct { AppType helper.AppType `json:"appType"` } +type CreateWorkflowMappingDto struct { + oldAppId int + newAppId int + userId int32 + newWfId int + gitMaterialMapping map[int]int + isSameProject bool + externalCiPipelineId int +} + func (impl *AppCloneServiceImpl) CloneApp(createReq *bean.CreateAppDTO, context context.Context) (*bean.CreateAppDTO, error) { //validate template app templateApp, err := impl.appRepository.FindById(createReq.TemplateId) @@ -586,6 +603,7 @@ func (impl *AppCloneServiceImpl) CreateWf(oldAppId, newAppId int, userId int32, return nil, err } impl.logger.Debugw("workflow found", "wf", refAppWFs) + for _, refAppWF := range refAppWFs { thisWf := appWorkflow.AppWorkflowDto{ Id: 0, @@ -594,24 +612,38 @@ func (impl *AppCloneServiceImpl) CreateWf(oldAppId, newAppId int, userId int32, AppWorkflowMappingDto: nil, //first create new mapping then add it UserId: userId, } + thisWf, err = impl.appWorkflowService.CreateAppWorkflow(thisWf) + if err != nil { + impl.logger.Errorw("error in creating workflow without external-ci", "err", err) + return nil, err + } isExternalCiPresent := false for _, awm := range refAppWF.AppWorkflowMappingDto { if awm.Type == appWorkflow2.WEBHOOK { isExternalCiPresent = true + break } } - - if !isExternalCiPresent { - thisWf, err = impl.appWorkflowService.CreateAppWorkflow(thisWf) - impl.logger.Debugw("workflow found", thisWf) + createWorkflowMappingDto := CreateWorkflowMappingDto{ + newAppId: newAppId, + oldAppId: oldAppId, + newWfId: thisWf.Id, + userId: userId, + } + var externalCiPipelineId int + if isExternalCiPresent { + externalCiPipelineId, err = impl.createExternalCiAndAppWorkflowMapping(createWorkflowMappingDto) if err != nil { - impl.logger.Errorw("errir in creating workflow without extenal-ci", "err", err) + impl.logger.Errorw("error in createExternalCiAndAppWorkflowMapping", "err", err) return nil, err } } + createWorkflowMappingDto.gitMaterialMapping = gitMaterialMapping + createWorkflowMappingDto.isSameProject = isSameProject + createWorkflowMappingDto.externalCiPipelineId = externalCiPipelineId - err = impl.createWfMappings(refAppWF.AppWorkflowMappingDto, oldAppId, newAppId, userId, thisWf.Id, gitMaterialMapping, ctx, isSameProject) + err = impl.createWfInstances(refAppWF.AppWorkflowMappingDto, createWorkflowMappingDto, ctx) if err != nil { impl.logger.Errorw("error in creating workflow mapping", "err", err) return nil, err @@ -620,7 +652,28 @@ func (impl *AppCloneServiceImpl) CreateWf(oldAppId, newAppId int, userId int32, return nil, nil } -func (impl *AppCloneServiceImpl) createWfMappings(refWfMappings []appWorkflow.AppWorkflowMappingDto, oldAppId, newAppId int, userId int32, thisWfId int, gitMaterialMapping map[int]int, ctx context.Context, isSameProject bool) error { +func (impl *AppCloneServiceImpl) createExternalCiAndAppWorkflowMapping(createWorkflowMappingDto CreateWorkflowMappingDto) (int, error) { + dbConnection := impl.pipelineRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + impl.logger.Errorw("error in beginning transaction", "err", err) + return 0, err + } + // Rollback tx on error. + defer tx.Rollback() + externalCiPipelineId, err := impl.pipelineBuilder.CreateExternalCiAndAppWorkflowMapping(createWorkflowMappingDto.newAppId, createWorkflowMappingDto.newWfId, createWorkflowMappingDto.userId, tx) + if err != nil { + impl.logger.Errorw("error in creating new external ci pipeline and new app workflow mapping", "refAppId", createWorkflowMappingDto.oldAppId, "newAppId", createWorkflowMappingDto.newAppId, "err", err) + return 0, err + } + err = tx.Commit() + if err != nil { + return 0, err + } + return externalCiPipelineId, nil +} + +func (impl *AppCloneServiceImpl) createWfInstances(refWfMappings []appWorkflow.AppWorkflowMappingDto, createWorkflowMappingDto CreateWorkflowMappingDto, ctx context.Context) error { impl.logger.Debugw("wf mapping cloning", "refWfMappings", refWfMappings) var ciMapping []appWorkflow.AppWorkflowMappingDto var cdMappings []appWorkflow.AppWorkflowMappingDto @@ -636,23 +689,30 @@ func (impl *AppCloneServiceImpl) createWfMappings(refWfMappings []appWorkflow.Ap return fmt.Errorf("unsupported wf type: %s", appWf.Type) } } - refApp, err := impl.pipelineBuilder.GetApp(oldAppId) + sourceToNewPipelineIdMapping := make(map[int]int) + refApp, err := impl.pipelineBuilder.GetApp(createWorkflowMappingDto.oldAppId) + if err != nil { + impl.logger.Errorw("error in getting app from refAppId", "refAppId", createWorkflowMappingDto.oldAppId) + return err + } if len(webhookMappings) > 0 { - if isSameProject { + if createWorkflowMappingDto.isSameProject { for _, refwebhookMappings := range cdMappings { cdCloneReq := &cloneCdPipelineRequest{ - refCdPipelineId: refwebhookMappings.ComponentId, - refAppId: oldAppId, - appId: newAppId, - userId: userId, - ciPipelineId: 0, - appWfId: thisWfId, - refAppName: refApp.AppName, + refCdPipelineId: refwebhookMappings.ComponentId, + refAppId: createWorkflowMappingDto.oldAppId, + appId: createWorkflowMappingDto.newAppId, + userId: createWorkflowMappingDto.userId, + ciPipelineId: 0, + appWfId: createWorkflowMappingDto.newWfId, + refAppName: refApp.AppName, + sourceToNewPipelineId: sourceToNewPipelineIdMapping, + externalCiPipelineId: createWorkflowMappingDto.externalCiPipelineId, } pipeline, err := impl.CreateCdPipeline(cdCloneReq, ctx) impl.logger.Debugw("cd pipeline created", "pipeline", pipeline) if err != nil { - impl.logger.Errorw("error in getting cd-pipeling", "err", err) + impl.logger.Errorw("error in getting cd-pipeline", "refAppId", createWorkflowMappingDto.oldAppId, "newAppId", createWorkflowMappingDto.newAppId, "err", err) return err } } @@ -666,7 +726,7 @@ func (impl *AppCloneServiceImpl) createWfMappings(refWfMappings []appWorkflow.Ap impl.logger.Warn("no ci pipeline found") return nil } else if len(ciMapping) != 1 { - impl.logger.Warn("more than one cd pipeline not supported") + impl.logger.Warn("more than one ci pipeline not supported") return nil } @@ -678,12 +738,12 @@ func (impl *AppCloneServiceImpl) createWfMappings(refWfMappings []appWorkflow.Ap impl.logger.Debugw("creating ci", "ref", refCiMapping) cloneCiPipelineRequest := &cloneCiPipelineRequest{ - refAppId: oldAppId, + refAppId: createWorkflowMappingDto.oldAppId, refCiPipelineId: refCiMapping.ComponentId, - userId: userId, - appId: newAppId, - wfId: thisWfId, - gitMaterialMapping: gitMaterialMapping, + userId: createWorkflowMappingDto.userId, + appId: createWorkflowMappingDto.newAppId, + wfId: createWorkflowMappingDto.newWfId, + gitMaterialMapping: createWorkflowMappingDto.gitMaterialMapping, refAppName: refApp.AppName, } ci, err = impl.CreateCiPipeline(cloneCiPipelineRequest) @@ -693,16 +753,18 @@ func (impl *AppCloneServiceImpl) createWfMappings(refWfMappings []appWorkflow.Ap } impl.logger.Debugw("ci created", "ci", ci) } - if isSameProject { + + if createWorkflowMappingDto.isSameProject { for _, refCdMapping := range cdMappings { cdCloneReq := &cloneCdPipelineRequest{ - refCdPipelineId: refCdMapping.ComponentId, - refAppId: oldAppId, - appId: newAppId, - userId: userId, - ciPipelineId: ci.CiPipelines[0].Id, - appWfId: thisWfId, - refAppName: refApp.AppName, + refCdPipelineId: refCdMapping.ComponentId, + refAppId: createWorkflowMappingDto.oldAppId, + appId: createWorkflowMappingDto.newAppId, + userId: createWorkflowMappingDto.userId, + ciPipelineId: ci.CiPipelines[0].Id, + appWfId: createWorkflowMappingDto.newWfId, + refAppName: refApp.AppName, + sourceToNewPipelineId: sourceToNewPipelineIdMapping, } pipeline, err := impl.CreateCdPipeline(cdCloneReq, ctx) if err != nil { @@ -866,13 +928,15 @@ func (impl *AppCloneServiceImpl) CreateCiPipeline(req *cloneCiPipelineRequest) ( } type cloneCdPipelineRequest struct { - refCdPipelineId int - refAppId int - appId int - userId int32 - ciPipelineId int - appWfId int - refAppName string + refCdPipelineId int + refAppId int + appId int + userId int32 + ciPipelineId int + appWfId int + refAppName string + sourceToNewPipelineId map[int]int + externalCiPipelineId int } func (impl *AppCloneServiceImpl) CreateCdPipeline(req *cloneCdPipelineRequest, ctx context.Context) (*bean.CdPipelines, error) { @@ -890,6 +954,7 @@ func (impl *AppCloneServiceImpl) CreateCdPipeline(req *cloneCdPipelineRequest, c if refCdPipeline == nil { return nil, fmt.Errorf("no cd pipeline found") } + refCdPipeline.SourceToNewPipelineId = req.sourceToNewPipelineId pipelineName := refCdPipeline.Name if strings.HasPrefix(pipelineName, req.refAppName) { pipelineName = strings.Replace(pipelineName, req.refAppName+"-", "", 1) @@ -920,35 +985,6 @@ func (impl *AppCloneServiceImpl) CreateCdPipeline(req *cloneCdPipelineRequest, c deploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM } - if refCdPipeline.ParentPipelineType == "WEBHOOK" { - cdPipeline := &bean.CDPipelineConfigObject{ - Id: 0, - EnvironmentId: refCdPipeline.EnvironmentId, - CiPipelineId: 0, - TriggerType: refCdPipeline.TriggerType, - Name: pipelineName, - Strategies: refCdPipeline.Strategies, - Namespace: refCdPipeline.Namespace, - AppWorkflowId: 0, - DeploymentTemplate: refCdPipeline.DeploymentTemplate, - PreStage: refCdPipeline.PreStage, //FIXME - PostStage: refCdPipeline.PostStage, - PreStageConfigMapSecretNames: refCdPipeline.PreStageConfigMapSecretNames, - PostStageConfigMapSecretNames: refCdPipeline.PostStageConfigMapSecretNames, - RunPostStageInEnv: refCdPipeline.RunPostStageInEnv, - RunPreStageInEnv: refCdPipeline.RunPreStageInEnv, - DeploymentAppType: refCdPipeline.DeploymentAppType, - ParentPipelineId: 0, - ParentPipelineType: refCdPipeline.ParentPipelineType, - } - cdPipelineReq := &bean.CdPipelines{ - Pipelines: []*bean.CDPipelineConfigObject{cdPipeline}, - AppId: req.appId, - UserId: req.userId, - } - cdPipelineRes, err := impl.pipelineBuilder.CreateCdPipelines(cdPipelineReq, ctx) - return cdPipelineRes, err - } cdPipeline := &bean.CDPipelineConfigObject{ Id: 0, EnvironmentId: refCdPipeline.EnvironmentId, @@ -968,6 +1004,15 @@ func (impl *AppCloneServiceImpl) CreateCdPipeline(req *cloneCdPipelineRequest, c DeploymentAppType: deploymentAppType, PreDeployStage: refCdPipeline.PreDeployStage, PostDeployStage: refCdPipeline.PostDeployStage, + SourceToNewPipelineId: refCdPipeline.SourceToNewPipelineId, + RefPipelineId: refCdPipeline.Id, + ParentPipelineType: refCdPipeline.ParentPipelineType, + } + if refCdPipeline.ParentPipelineType == "WEBHOOK" { + cdPipeline.CiPipelineId = 0 + cdPipeline.ParentPipelineId = req.externalCiPipelineId + } else if refCdPipeline.ParentPipelineType != appWorkflow.CI_PIPELINE_TYPE { + cdPipeline.ParentPipelineId = refCdPipeline.ParentPipelineId } cdPipelineReq := &bean.CdPipelines{ Pipelines: []*bean.CDPipelineConfigObject{cdPipeline}, diff --git a/pkg/bean/app.go b/pkg/bean/app.go index ffdc2e1458..4370081007 100644 --- a/pkg/bean/app.go +++ b/pkg/bean/app.go @@ -529,6 +529,9 @@ type CDPipelineConfigObject struct { ManifestStorageType string `json:"manifestStorageType"` PreDeployStage *bean.PipelineStageDto `json:"preDeployStage,omitempty"` PostDeployStage *bean.PipelineStageDto `json:"postDeployStage,omitempty"` + SourceToNewPipelineId map[int]int `json:"sourceToNewPipelineId,omitempty"` + RefPipelineId int `json:"refPipelineId,omitempty"` + ExternalCiPipelineId int `json:"externalCiPipelineId,omitempty"` } type PreStageConfigMapSecretNames struct { diff --git a/pkg/pipeline/PipelineBuilder.go b/pkg/pipeline/PipelineBuilder.go index 48d0f3d749..999e6a073a 100644 --- a/pkg/pipeline/PipelineBuilder.go +++ b/pkg/pipeline/PipelineBuilder.go @@ -171,6 +171,8 @@ type PipelineBuilder interface { GetAppListForEnvironment(request appGroup2.AppGroupingRequest) ([]*AppBean, error) GetDeploymentConfigMap(environmentId int) (map[string]bool, error) IsGitopsConfigured() (bool, error) + + CreateExternalCiAndAppWorkflowMapping(appId, appWorkflowId int, userId int32, tx *pg.Tx) (int, error) } type PipelineBuilderImpl struct { logger *zap.SugaredLogger @@ -3037,15 +3039,7 @@ func (impl *PipelineBuilderImpl) createCdPipeline(ctx context.Context, app *app2 } // Rollback tx on error. defer tx.Rollback() - if pipeline.AppWorkflowId == 0 && pipeline.ParentPipelineType == "WEBHOOK" { - externalCiPipeline := &pipelineConfig.ExternalCiPipeline{ - AppId: app.Id, - AccessToken: "", - Active: true, - AuditLog: sql.AuditLog{CreatedBy: userId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: userId}, - } - externalCiPipeline, err = impl.ciPipelineRepository.SaveExternalCi(externalCiPipeline, tx) wf := &appWorkflow.AppWorkflow{ Name: fmt.Sprintf("wf-%d-%s", app.Id, util2.Generate(4)), AppId: app.Id, @@ -3054,21 +3048,15 @@ func (impl *PipelineBuilderImpl) createCdPipeline(ctx context.Context, app *app2 } savedAppWf, err := impl.appWorkflowRepository.SaveAppWorkflowWithTx(wf, tx) if err != nil { - impl.logger.Errorw("err", err) + impl.logger.Errorw("error in saving app workflow", "appId", app.Id, "err", err) return 0, err } - appWorkflowMap := &appWorkflow.AppWorkflowMapping{ - AppWorkflowId: savedAppWf.Id, - ComponentId: externalCiPipeline.Id, - Type: "WEBHOOK", - Active: true, - AuditLog: sql.AuditLog{CreatedBy: userId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: userId}, - } - appWorkflowMap, err = impl.appWorkflowRepository.SaveAppWorkflowMapping(appWorkflowMap, tx) + externalCiPipelineId, err := impl.CreateExternalCiAndAppWorkflowMapping(app.Id, savedAppWf.Id, userId, tx) if err != nil { + impl.logger.Errorw("error in creating new external ci pipeline and new app workflow mapping", "appId", app.Id, "err", err) return 0, err } - pipeline.ParentPipelineId = externalCiPipeline.Id + pipeline.ParentPipelineId = externalCiPipelineId pipeline.AppWorkflowId = savedAppWf.Id } @@ -3085,9 +3073,12 @@ func (impl *PipelineBuilderImpl) createCdPipeline(ctx context.Context, app *app2 //TODO: mark as created in our db pipelineId, err := impl.ciCdPipelineOrchestrator.CreateCDPipelines(pipeline, app.Id, userId, tx, app.AppName) if err != nil { - impl.logger.Errorw("error in ") + impl.logger.Errorw("error in creating cd pipeline", "appId", app.Id, "pipeline", pipeline) return 0, err } + if pipeline.RefPipelineId > 0 { + pipeline.SourceToNewPipelineId[pipeline.RefPipelineId] = pipelineId + } //adding pipeline to workflow _, err = impl.appWorkflowRepository.FindByIdAndAppId(pipeline.AppWorkflowId, app.Id) @@ -3097,12 +3088,16 @@ func (impl *PipelineBuilderImpl) createCdPipeline(ctx context.Context, app *app2 if pipeline.AppWorkflowId > 0 { var parentPipelineId int var parentPipelineType string + if pipeline.ParentPipelineId == 0 { parentPipelineId = pipeline.CiPipelineId parentPipelineType = "CI_PIPELINE" } else { parentPipelineId = pipeline.ParentPipelineId parentPipelineType = pipeline.ParentPipelineType + if pipeline.ParentPipelineType != appWorkflow.WEBHOOK && pipeline.RefPipelineId > 0 && len(pipeline.SourceToNewPipelineId) > 0 { + parentPipelineId = pipeline.SourceToNewPipelineId[pipeline.ParentPipelineId] + } } appWorkflowMap := &appWorkflow.AppWorkflowMapping{ AppWorkflowId: pipeline.AppWorkflowId, @@ -3177,6 +3172,33 @@ func (impl *PipelineBuilderImpl) createCdPipeline(ctx context.Context, app *app2 return pipelineId, nil } +func (impl PipelineBuilderImpl) CreateExternalCiAndAppWorkflowMapping(appId, appWorkflowId int, userId int32, tx *pg.Tx) (int, error) { + externalCiPipeline := &pipelineConfig.ExternalCiPipeline{ + AppId: appId, + AccessToken: "", + Active: true, + AuditLog: sql.AuditLog{CreatedBy: userId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: userId}, + } + externalCiPipeline, err := impl.ciPipelineRepository.SaveExternalCi(externalCiPipeline, tx) + if err != nil { + impl.logger.Errorw("error in saving external ci", "appId", appId, "err", err) + return 0, err + } + appWorkflowMap := &appWorkflow.AppWorkflowMapping{ + AppWorkflowId: appWorkflowId, + ComponentId: externalCiPipeline.Id, + Type: "WEBHOOK", + Active: true, + AuditLog: sql.AuditLog{CreatedBy: userId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: userId}, + } + appWorkflowMap, err = impl.appWorkflowRepository.SaveAppWorkflowMapping(appWorkflowMap, tx) + if err != nil { + impl.logger.Errorw("error in saving app workflow mapping for external ci", "appId", appId, "appWorkflowId", appWorkflowId, "externalCiPipelineId", externalCiPipeline.Id, "err", err) + return 0, err + } + return externalCiPipeline.Id, nil +} + func (impl PipelineBuilderImpl) extractAndMapVariables(template string, entityId int, entityType repository6.EntityType, userId int32) error { usedVariables, err := impl.variableTemplateParser.ExtractVariables(template) if err != nil { diff --git a/wire_gen.go b/wire_gen.go index b155447916..37feb1f442 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -485,7 +485,7 @@ func InitializeApp() (*App, error) { deploymentEventHandlerImpl := app2.NewDeploymentEventHandlerImpl(sugaredLogger, appListingServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl) cdHandlerImpl := pipeline.NewCdHandlerImpl(sugaredLogger, cdConfig, userServiceImpl, cdWorkflowRepositoryImpl, cdWorkflowServiceImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, ciPipelineMaterialRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, ciWorkflowRepositoryImpl, ciConfig, helmAppServiceImpl, pipelineOverrideRepositoryImpl, workflowDagExecutorImpl, appListingServiceImpl, appListingRepositoryImpl, pipelineStatusTimelineRepositoryImpl, applicationServiceClientImpl, argoUserServiceImpl, deploymentEventHandlerImpl, eventRESTClientImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceImpl, appStatusServiceImpl, enforcerUtilImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, appRepositoryImpl, appGroupServiceImpl, imageTaggingServiceImpl, k8sUtil) appWorkflowServiceImpl := appWorkflow2.NewAppWorkflowServiceImpl(sugaredLogger, appWorkflowRepositoryImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, appGroupServiceImpl) - appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, materialRepositoryImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, ciTemplateOverrideRepositoryImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl) + appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, materialRepositoryImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, ciTemplateOverrideRepositoryImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, appWorkflowRepositoryImpl) imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) cveStoreRepositoryImpl := security.NewCveStoreRepositoryImpl(db, sugaredLogger) policyServiceImpl := security2.NewPolicyServiceImpl(environmentServiceImpl, sugaredLogger, appRepositoryImpl, pipelineOverrideRepositoryImpl, cvePolicyRepositoryImpl, clusterServiceImplExtended, pipelineRepositoryImpl, imageScanResultRepositoryImpl, imageScanDeployInfoRepositoryImpl, imageScanObjectMetaRepositoryImpl, httpClient, ciArtifactRepositoryImpl, ciConfig, imageScanHistoryRepositoryImpl, cveStoreRepositoryImpl, ciTemplateRepositoryImpl)