diff --git a/internal/services/gateway/webhook.go b/internal/services/gateway/webhook.go index a9c2a28..071b643 100644 --- a/internal/services/gateway/webhook.go +++ b/internal/services/gateway/webhook.go @@ -49,8 +49,6 @@ const ( AnnotationRunType = "runtype" AnnotationProjectID = "projectid" AnnotationUserID = "userid" - // AnnotationVirtualBranch represent a "virtual branch": i.e a normal branch, a pr (with name pr-$prid), a tag (with name tag-tagname) - AnnotationVirtualBranch = "virtual_branch" AnnotationCommitSHA = "commit_sha" AnnotationRef = "ref" @@ -67,19 +65,6 @@ const ( AnnotationPullRequestLink = "pull_request_link" ) -func genAnnotationVirtualBranch(webhookData *types.WebhookData) string { - switch webhookData.Event { - case types.WebhookEventPush: - return "branch-" + webhookData.Branch - case types.WebhookEventTag: - return "tag-" + webhookData.Tag - case types.WebhookEventPullRequest: - return "pr-" + webhookData.PullRequestID - } - - panic(fmt.Errorf("invalid webhook event type: %q", webhookData.Event)) -} - type webhooksHandler struct { log *zap.SugaredLogger ah *action.ActionHandler @@ -274,15 +259,14 @@ func (h *webhooksHandler) handleWebhook(r *http.Request) (int, string, error) { } annotations := map[string]string{ - AnnotationRunType: string(runType), - AnnotationEventType: string(webhookData.Event), - AnnotationVirtualBranch: genAnnotationVirtualBranch(webhookData), - AnnotationCommitSHA: webhookData.CommitSHA, - AnnotationRef: webhookData.Ref, - AnnotationSender: webhookData.Sender, - AnnotationMessage: webhookData.Message, - AnnotationCommitLink: webhookData.CommitLink, - AnnotationCompareLink: webhookData.CompareLink, + AnnotationRunType: string(runType), + AnnotationEventType: string(webhookData.Event), + AnnotationCommitSHA: webhookData.CommitSHA, + AnnotationRef: webhookData.Ref, + AnnotationSender: webhookData.Sender, + AnnotationMessage: webhookData.Message, + AnnotationCommitLink: webhookData.CommitLink, + AnnotationCompareLink: webhookData.CompareLink, } if !isUserBuild {