From a968b068aef4f41fbb3e436a31b4c1ba310ef36c Mon Sep 17 00:00:00 2001 From: Ryan Hopper-Lowe <46546486+ryanhopperlowe@users.noreply.github.com> Date: Tue, 26 Nov 2024 08:49:48 -0600 Subject: [PATCH] fix: webhooks getting not found error when triggering workflows (#671) * fix: webhooks getting not found error when triggering webhooks Signed-off-by: Ryan Hopper-Lowe * fix: include dynamic namespaces for webhook execution --------- Signed-off-by: Ryan Hopper-Lowe --- pkg/api/handlers/webhooks.go | 4 ++-- pkg/api/router/router.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/api/handlers/webhooks.go b/pkg/api/handlers/webhooks.go index 3bf0d3b56..1498c1744 100644 --- a/pkg/api/handlers/webhooks.go +++ b/pkg/api/handlers/webhooks.go @@ -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 @@ -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 } diff --git a/pkg/api/router/router.go b/pkg/api/router/router.go index 371b9a76b..01c73c2bb 100644 --- a/pkg/api/router/router.go +++ b/pkg/api/router/router.go @@ -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)