-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement custom trigger for webhooks #9879
Changes from 20 commits
3656619
5ec4d27
286bf9b
3794fcc
43e5b10
42df954
cc17f20
224ccea
f4399b4
e4a581b
fef27b6
807536b
bd52183
5717149
0b2020c
b2e8f0b
1f973bc
bf74df2
e6b3a95
f334a55
f72241e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,13 @@ func (a *WebhooksAPIServer) PostWebhook( | |
regexConditionKey, m) | ||
} | ||
} | ||
if t.TriggerType == webhookv1.TriggerType_TRIGGER_TYPE_CUSTOM { | ||
if req.Webhook.Mode != webhookv1.WebhookMode_WEBHOOK_MODE_SPECIFIC { | ||
return nil, status.Errorf(codes.InvalidArgument, | ||
"custom trigger only works on webhook with mode 'SPECIFIC'. Got %v", | ||
req.Webhook.Mode) | ||
} | ||
} | ||
} | ||
|
||
w := WebhookFromProto(req.Webhook) | ||
|
@@ -223,3 +230,29 @@ func (a *WebhooksAPIServer) TestWebhook( | |
} | ||
return &apiv1.TestWebhookResponse{}, nil | ||
} | ||
|
||
// PostWebhookEventData handles data for custom trigger. | ||
func (a *WebhooksAPIServer) PostWebhookEventData( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we maybe add a couple of integration tests for this function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e2e tests for this function were accidentally dropped during a merge, now they should be restored |
||
ctx context.Context, req *apiv1.PostWebhookEventDataRequest, | ||
) (*apiv1.PostWebhookEventDataResponse, error) { | ||
var res apiv1.PostWebhookEventDataResponse | ||
_, _, err := grpcutil.GetUser(ctx) | ||
if err != nil { | ||
return &res, status.Errorf(codes.Internal, "failed to get the user: %s", err) | ||
} | ||
|
||
var data CustomTriggerData | ||
if req.Data != nil { | ||
data.Title = req.Data.Title | ||
data.Description = req.Data.Description | ||
data.Level = model.TaskLogLevelFromProto(req.Data.Level) | ||
} | ||
err = handleCustomTriggerData(ctx, data, int(req.ExperimentId), ptrs.Ptr(int(req.TrialId))) | ||
if err != nil { | ||
return &res, status.Errorf(codes.Internal, | ||
"failed to handle custom trigger data: %+v experiment id: %d trial_id %d : %s", | ||
data, req.ExperimentId, req.TrialId, err) | ||
} | ||
|
||
return &res, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my understanding, why do we need
info
now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we want to access the experiment id and trial id in
alert
function