Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
fix: Use event type as task for non-task events (#670)
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Pitman <[email protected]>
  • Loading branch information
arthurpitman authored Jan 11, 2022
1 parent 3dc1e63 commit b112d2c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions internal/event_handler/error_event_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ func NewErrorEventFactory(event cloudevents.Event, err error, integrationID stri
}

func (f *ErrorEventFactory) CreateCloudEvent() (*cloudevents.Event, error) {

taskName, _, err := keptnv2.ParseTaskEventType(f.evt.Type())
if err != nil {
log.WithError(err).Warnf("could not extract task name from event type: %s, will set it to full type", f.evt.Type())
taskName = f.evt.Type()
}

errorData := ErrorData{
Message: f.err.Error(),
IntegrationID: f.integrationID,
Task: taskName,
Task: getTaskFromEvent(f.evt.Type()),
}

return adapter.NewCloudEventFactory(
Expand All @@ -50,3 +43,17 @@ func (f *ErrorEventFactory) CreateCloudEvent() (*cloudevents.Event, error) {
errorData,
).CreateCloudEvent()
}

func getTaskFromEvent(eventType string) string {
if !keptnv2.IsTaskEventType(eventType) {
return eventType
}

taskName, _, err := keptnv2.ParseTaskEventType(eventType)
if err != nil {
log.WithError(err).Warnf("could not extract task name from event type: %s, will set it to full type", eventType)
return eventType
}

return taskName
}

0 comments on commit b112d2c

Please sign in to comment.