From 9d30f078b8dc74cda85671fe2cdd48fd8f266240 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Wed, 20 Nov 2024 13:09:37 -0500 Subject: [PATCH] fix: return webhook invoke URL in API Signed-off-by: Donnie Adams --- pkg/api/handlers/webhooks.go | 8 ++++++-- pkg/storage/apis/otto.otto8.ai/v1/webhook.go | 1 - pkg/storage/openapi/generated/openapi_generated.go | 6 ------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/api/handlers/webhooks.go b/pkg/api/handlers/webhooks.go index 7378ec62..e0132a1c 100644 --- a/pkg/api/handlers/webhooks.go +++ b/pkg/api/handlers/webhooks.go @@ -132,8 +132,12 @@ func (a *WebhookHandler) Create(req api.Context) error { func convertWebhook(webhook v1.Webhook, urlPrefix string) *types.Webhook { var links []string - if urlPrefix != "" && webhook.Status.Alias != "" { - links = []string{"invoke", fmt.Sprintf("%s/webhooks/%s", urlPrefix, webhook.Status.Alias)} + if urlPrefix != "" { + path := webhook.Name + if webhook.Status.AliasAssigned { + path = webhook.Spec.Alias + } + links = []string{"invoke", fmt.Sprintf("%s/webhooks/%s", urlPrefix, path)} } manifest := webhook.Spec.WebhookManifest diff --git a/pkg/storage/apis/otto.otto8.ai/v1/webhook.go b/pkg/storage/apis/otto.otto8.ai/v1/webhook.go index c155fe63..d44edb19 100644 --- a/pkg/storage/apis/otto.otto8.ai/v1/webhook.go +++ b/pkg/storage/apis/otto.otto8.ai/v1/webhook.go @@ -58,7 +58,6 @@ type WebhookSpec struct { } type WebhookStatus struct { - Alias string `json:"alias,omitempty"` AliasAssigned bool `json:"aliasAssigned,omitempty"` LastSuccessfulRunCompleted *metav1.Time `json:"lastSuccessfulRunCompleted,omitempty"` } diff --git a/pkg/storage/openapi/generated/openapi_generated.go b/pkg/storage/openapi/generated/openapi_generated.go index 6ead1025..f146ee66 100644 --- a/pkg/storage/openapi/generated/openapi_generated.go +++ b/pkg/storage/openapi/generated/openapi_generated.go @@ -6382,12 +6382,6 @@ func schema_storage_apis_ottootto8ai_v1_WebhookStatus(ref common.ReferenceCallba SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "alias": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, "aliasAssigned": { SchemaProps: spec.SchemaProps{ Type: []string{"boolean"},