Skip to content

Commit

Permalink
fix: webhooks getting not found error when triggering workflows (#671)
Browse files Browse the repository at this point in the history
* fix: webhooks getting not found error when triggering webhooks

Signed-off-by: Ryan Hopper-Lowe <[email protected]>

* fix: include dynamic namespaces for webhook execution

---------

Signed-off-by: Ryan Hopper-Lowe <[email protected]>
  • Loading branch information
ryanhopperlowe authored Nov 26, 2024
1 parent c21c8f1 commit a968b06
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/api/handlers/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func convertWebhook(webhook v1.Webhook, urlPrefix string) *types.Webhook {
if webhook.Status.AliasAssigned {
path = webhook.Spec.Alias
}
links = []string{"invoke", fmt.Sprintf("%s/webhooks/%s", urlPrefix, path)}
links = []string{"invoke", fmt.Sprintf("%s/webhooks/%s/%s", urlPrefix, webhook.Namespace, path)}
}

manifest := webhook.Spec.WebhookManifest
Expand Down Expand Up @@ -195,7 +195,7 @@ func (a *WebhookHandler) RemoveToken(req api.Context) error {

func (a *WebhookHandler) Execute(req api.Context) error {
var webhook v1.Webhook
if err := alias.Get(req.Context(), req.Storage, &webhook, "", req.PathValue("id")); err != nil {
if err := alias.Get(req.Context(), req.Storage, &webhook, req.PathValue("namespace"), req.PathValue("id")); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func Router(services *services.Services) (http.Handler, error) {
mux.HandleFunc("GET /api/webhooks/{id}", webhooks.ByID)
mux.HandleFunc("DELETE /api/webhooks/{id}", webhooks.Delete)
mux.HandleFunc("PUT /api/webhooks/{id}", webhooks.Update)
mux.HandleFunc("POST /api/webhooks/{id}", webhooks.Execute)
mux.HandleFunc("POST /api/webhooks/{id}/remove-token", webhooks.RemoveToken)
mux.HandleFunc("POST /api/webhooks/{namespace}/{id}", webhooks.Execute)

// Email Receivers
mux.HandleFunc("POST /api/email-receivers", emailreceiver.Create)
Expand Down

0 comments on commit a968b06

Please sign in to comment.