Skip to content

Commit

Permalink
fix(cloudevents): fix notify conditions
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo committed Dec 20, 2023
1 parent c29315c commit e6c3b15
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
15 changes: 11 additions & 4 deletions cloudevents-server/pkg/events/custom/tekton/handler_pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ type pipelineRunHandler struct {
func (h *pipelineRunHandler) SupportEventTypes() []string {
return []string{
string(tektoncloudevent.PipelineRunFailedEventV1),
// string(tektoncloudevent.PipelineRunRunningEventV1),
string(tektoncloudevent.PipelineRunRunningEventV1),
string(tektoncloudevent.PipelineRunStartedEventV1),
string(tektoncloudevent.PipelineRunSuccessfulEventV1),
// string(tektoncloudevent.PipelineRunUnknownEventV1),
string(tektoncloudevent.PipelineRunUnknownEventV1),
}
}

Expand All @@ -32,8 +32,15 @@ func (h *pipelineRunHandler) Handle(event cloudevents.Event) cloudevents.Result
return cloudevents.NewHTTPResult(http.StatusBadRequest, err.Error())
}

log.Debug().Str("ce-type", event.Type()).Msg("skip notifing for the event type.")
return cloudevents.ResultACK
switch tektoncloudevent.TektonEventType(event.Type()) {
case tektoncloudevent.PipelineRunStartedEventV1,
tektoncloudevent.PipelineRunFailedEventV1,
tektoncloudevent.PipelineRunSuccessfulEventV1:
return h.notifyRunStatus(event)
default:
log.Debug().Str("ce-type", event.Type()).Msg("skip notifing for the event type.")
return cloudevents.ResultACK
}
}

func (h *pipelineRunHandler) notifyRunStatus(event cloudevents.Event) cloudevents.Result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ func (h *taskRunHandler) Handle(event cloudevents.Event) cloudevents.Result {
return cloudevents.NewHTTPResult(http.StatusBadRequest, err.Error())
}

log.Debug().Str("ce-type", event.Type()).Msg("skip notifing for the event type.")
return cloudevents.ResultACK
switch event.Type() {
case string(tektoncloudevent.TaskRunFailedEventV1):
return h.notifyRunStatus(event)
default:
log.Debug().Str("ce-type", event.Type()).Msg("skip notifing for the event type.")
return cloudevents.ResultACK
}
}

func (h *taskRunHandler) notifyRunStatus(event cloudevents.Event) cloudevents.Result {
Expand Down

0 comments on commit e6c3b15

Please sign in to comment.