Skip to content

Commit a186761

Browse files
committed
more refact
1 parent 9a48729 commit a186761

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

client/events/EventBuilder.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ func (impl *EventSimpleFactoryImpl) BuildExtraCIData(event Event, material *Mate
204204
payload.TriggeredBy = user.EmailId
205205
event.Payload = payload
206206
}
207+
208+
// fetching all the envs which are directly or indirectly linked with the ci pipeline
209+
if event.PipelineId > 0 {
210+
// Get the pipeline to check if it's external
211+
ciPipeline, err := impl.ciPipelineRepository.FindById(event.PipelineId)
212+
if err != nil {
213+
impl.logger.Errorw("error in getting ci pipeline", "pipelineId", event.PipelineId, "err", err)
214+
} else {
215+
envs, err := impl.envRepository.FindEnvLinkedWithCiPipelines(ciPipeline.IsExternal, []int{event.PipelineId})
216+
if err != nil {
217+
impl.logger.Errorw("error in finding environments linked with ci pipeline", "pipelineId", event.PipelineId, "err", err)
218+
} else {
219+
event.EnvIdsForCiPipeline = []int{}
220+
for _, env := range envs {
221+
event.EnvIdsForCiPipeline = append(event.EnvIdsForCiPipeline, env.Id)
222+
}
223+
}
224+
}
225+
}
226+
207227
return event
208228
}
209229

pkg/pipeline/CiService.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,6 @@ func (impl *CiServiceImpl) WriteCITriggerEvent(trigger types.Trigger, pipeline *
498498
event.CiWorkflowRunnerId = workflowRequest.WorkflowId
499499
event = impl.eventFactory.BuildExtraCIData(event, material)
500500

501-
// fetching all the envs which are directly or indirectly linked with the ci pipeline
502-
envs, _ := impl.envRepository.FindEnvLinkedWithCiPipelines(pipeline.IsExternal, []int{trigger.PipelineId})
503-
504-
event.EnvIdsForCiPipeline = []int{}
505-
for _, env := range envs {
506-
event.EnvIdsForCiPipeline = append(event.EnvIdsForCiPipeline, env.Id)
507-
}
508-
509501
_, evtErr := impl.eventClient.WriteNotificationEvent(event)
510502
if evtErr != nil {
511503
impl.Logger.Errorw("error in writing event", "err", evtErr)

0 commit comments

Comments
 (0)