Skip to content

Commit

Permalink
fix: slack messages not sending when there are no webhooks defined (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nicufk authored Jul 19, 2022
1 parent bd035e1 commit cdcdc20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/slacknotifier/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func SendEvent(eventType *testkube.WebhookEventType, execution testkube.Executio
}

args := messageArgs{
ExecutionID: execution.Id,
ExecutionID: execution.Name,
EventType: string(*eventType),
Namespace: execution.TestNamespace,
TestName: execution.TestName,
Expand Down
11 changes: 7 additions & 4 deletions pkg/webhook/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ type WebhookHttpResponse struct {

// Notify notifies emitter with webhook
func (s *Emitter) Notify(event testkube.WebhookEvent) {
s.Log.Debugw("notifying webhook", "event", event)
s.Log.Infow("notifying webhook", "event", event)
s.Events <- event
}

// RunWorkers runs emitter workers responsible for sending HTTP requests
func (s *Emitter) RunWorkers() {
s.Log.Debugw("Starting workers", "count", workersCount)
s.Log.Infow("Starting workers", "count", workersCount)
for i := 0; i < workersCount; i++ {
go s.Listen(s.Events)
}
Expand All @@ -64,9 +64,8 @@ func (s *Emitter) RunWorkers() {
// Listen listens for webhook events
func (s *Emitter) Listen(events chan testkube.WebhookEvent) {
for event := range events {
s.Log.Infow("processing event", "event", event)
s.sendHttpEvent(event)
// TODO webhooks should be designed as events with type webhook/slack
s.sendSlackEvent(event.Type_, *event.Execution)
}
}

Expand Down Expand Up @@ -127,6 +126,10 @@ func (s Emitter) NotifyAll(eventType *testkube.WebhookEventType, execution testk
})
}

// TODO webhooks should be designed as events with type webhook/slack
// TODO move it to Listen when the type webhook/slack is ready
s.sendSlackEvent(eventType, execution)

return nil

}
Expand Down

0 comments on commit cdcdc20

Please sign in to comment.