diff --git a/flyteadmin/pkg/async/webhook/factory.go b/flyteadmin/pkg/async/webhook/factory.go index fb38d35c0a..895b2b73db 100644 --- a/flyteadmin/pkg/async/webhook/factory.go +++ b/flyteadmin/pkg/async/webhook/factory.go @@ -6,21 +6,21 @@ import ( "time" gizmoGCP "github.com/NYTimes/gizmo/pubsub/gcp" - "github.com/flyteorg/flyteadmin/pkg/common" + "github.com/flyteorg/flyte/flyteadmin/pkg/common" - repoInterfaces "github.com/flyteorg/flyteadmin/pkg/repositories/interfaces" + repoInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/interfaces" "github.com/NYTimes/gizmo/pubsub" gizmoAWS "github.com/NYTimes/gizmo/pubsub/aws" - "github.com/flyteorg/flyteadmin/pkg/async" - notificationsImplementations "github.com/flyteorg/flyteadmin/pkg/async/notifications/implementations" - "github.com/flyteorg/flyteadmin/pkg/async/notifications/interfaces" - "github.com/flyteorg/flyteadmin/pkg/async/webhook/implementations" - "github.com/flyteorg/flytestdlib/logger" + "github.com/flyteorg/flyte/flyteadmin/pkg/async" + notificationsImplementations "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/implementations" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/webhook/implementations" + "github.com/flyteorg/flyte/flytestdlib/logger" - webhookInterfaces "github.com/flyteorg/flyteadmin/pkg/async/webhook/interfaces" - runtimeInterfaces "github.com/flyteorg/flyteadmin/pkg/runtime/interfaces" - "github.com/flyteorg/flytestdlib/promutils" + webhookInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/async/webhook/interfaces" + runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" + "github.com/flyteorg/flyte/flytestdlib/promutils" ) var enable64decoding = false diff --git a/flyteadmin/pkg/async/webhook/factory_test.go b/flyteadmin/pkg/async/webhook/factory_test.go index be078e35a9..94facca5a1 100644 --- a/flyteadmin/pkg/async/webhook/factory_test.go +++ b/flyteadmin/pkg/async/webhook/factory_test.go @@ -3,10 +3,10 @@ package webhook import ( "testing" - runtimeInterfaces "github.com/flyteorg/flyteadmin/pkg/runtime/interfaces" + runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" - "github.com/flyteorg/flyteadmin/pkg/async/webhook/implementations" - "github.com/flyteorg/flytestdlib/promutils" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/webhook/implementations" + "github.com/flyteorg/flyte/flytestdlib/promutils" ) func TestGetWebhook(t *testing.T) { diff --git a/flyteadmin/pkg/async/webhook/implementations/processer.go b/flyteadmin/pkg/async/webhook/implementations/processer.go index 9645b91a15..e77daa9146 100644 --- a/flyteadmin/pkg/async/webhook/implementations/processer.go +++ b/flyteadmin/pkg/async/webhook/implementations/processer.go @@ -37,7 +37,7 @@ func (p *Processor) StartProcessing() { } func (p *Processor) run() error { - var payload admin.WebhookPayload + var payload admin.WebhookMessage var request admin.WorkflowExecutionEventRequest var err error var subject string @@ -88,7 +88,7 @@ func (p *Processor) run() error { continue } - payload.Message = notifications.SubstituteParameters(p.webhook.GetConfig().Payload, request, adminExecution) + payload.Body = notifications.SubstituteParameters(p.webhook.GetConfig().Payload, request, adminExecution) logger.Info(context.Background(), "Processor is sending message to webhook endpoint") if err = p.webhook.Post(context.Background(), payload); err != nil { p.SystemMetrics.MessageProcessorError.Inc() diff --git a/flyteadmin/pkg/async/webhook/implementations/processor_test.go b/flyteadmin/pkg/async/webhook/implementations/processor_test.go index 086f97d048..e79cbed918 100644 --- a/flyteadmin/pkg/async/webhook/implementations/processor_test.go +++ b/flyteadmin/pkg/async/webhook/implementations/processor_test.go @@ -29,7 +29,7 @@ import ( var ( mockWebhook = mocks.MockWebhook{} repo = repositoryMocks.NewMockRepository() - testWebhook = admin.WebhookPayload{Message: "hello world"} + testWebhook = admin.WebhookMessage{Body: "hello world"} workflowRequest = &admin.WorkflowExecutionEventRequest{ Event: &event.WorkflowExecutionEvent{ Phase: core.WorkflowExecution_FAILED, @@ -69,8 +69,8 @@ func TestProcessor_StartProcessing(t *testing.T) { initializeProcessor() testSubscriber.JSONMessages = append(testSubscriber.JSONMessages, testSubscriberMessage) - sendWebhookValidationFunc := func(ctx context.Context, payload admin.WebhookPayload) error { - assert.Equal(t, payload.Message, testWebhook.Message) + sendWebhookValidationFunc := func(ctx context.Context, payload admin.WebhookMessage) error { + assert.Equal(t, payload.Body, testWebhook.Body) return nil } mockWebhook.SetWebhookPostFunc(sendWebhookValidationFunc) @@ -189,7 +189,7 @@ func TestProcessor_StartProcessingError(t *testing.T) { func TestProcessor_StartProcessingWebhookError(t *testing.T) { initializeProcessor() webhookError := errors.New("webhook error") - sendWebhookErrorFunc := func(ctx context.Context, payload admin.WebhookPayload) error { + sendWebhookErrorFunc := func(ctx context.Context, payload admin.WebhookMessage) error { return webhookError } mockWebhook.SetWebhookPostFunc(sendWebhookErrorFunc) diff --git a/flyteadmin/pkg/async/webhook/implementations/slack_webhook.go b/flyteadmin/pkg/async/webhook/implementations/slack_webhook.go index 29440377aa..3473c218cc 100644 --- a/flyteadmin/pkg/async/webhook/implementations/slack_webhook.go +++ b/flyteadmin/pkg/async/webhook/implementations/slack_webhook.go @@ -28,14 +28,14 @@ func (s *SlackWebhook) GetConfig() runtimeInterfaces.WebHookConfig { return s.Config } -func (s *SlackWebhook) Post(ctx context.Context, payload admin.WebhookPayload) error { +func (s *SlackWebhook) Post(ctx context.Context, payload admin.WebhookMessage) error { sm := secretmanager.NewFileEnvSecretManager(secretmanager.GetConfig()) webhookURL, err := sm.Get(ctx, s.Config.URLSecretName) if err != nil { logger.Errorf(ctx, "Failed to get url from secret manager with error: %v", err) return err } - data := []byte(fmt.Sprintf("{'text': '%s'}", payload.Message)) + data := []byte(fmt.Sprintf("{'text': '%s'}", payload.Body)) request, err := http.NewRequest("POST", webhookURL, bytes.NewBuffer(data)) if err != nil { logger.Errorf(ctx, "Failed to create request to Slack webhook with error: %v", err) diff --git a/flyteadmin/pkg/async/webhook/interfaces/webhook.go b/flyteadmin/pkg/async/webhook/interfaces/webhook.go index 95deca0505..cdceac3c51 100644 --- a/flyteadmin/pkg/async/webhook/interfaces/webhook.go +++ b/flyteadmin/pkg/async/webhook/interfaces/webhook.go @@ -3,8 +3,8 @@ package interfaces import ( "context" - runtimeInterfaces "github.com/flyteorg/flyteadmin/pkg/runtime/interfaces" - "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" + runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" ) //go:generate mockery -name=Webhook -output=../mocks -case=underscore @@ -16,6 +16,6 @@ type Payload struct { // Webhook Defines the interface for Publishing execution event to other services, such as slack. type Webhook interface { // Post The notificationType is inferred from the Notification object in the Execution Spec. - Post(ctx context.Context, payload admin.WebhookPayload) error + Post(ctx context.Context, payload admin.WebhookMessage) error GetConfig() runtimeInterfaces.WebHookConfig } diff --git a/flyteadmin/pkg/async/webhook/mocks/processor.go b/flyteadmin/pkg/async/webhook/mocks/processor.go index dbc6713b04..187d02d166 100644 --- a/flyteadmin/pkg/async/webhook/mocks/processor.go +++ b/flyteadmin/pkg/async/webhook/mocks/processor.go @@ -3,9 +3,9 @@ package mocks import ( "context" - runtimeInterfaces "github.com/flyteorg/flyteadmin/pkg/runtime/interfaces" + runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" - "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" ) type RunFunc func() error diff --git a/flyteadmin/pkg/async/webhook/mocks/webhook.go b/flyteadmin/pkg/async/webhook/mocks/webhook.go index b0f84498cd..5f51637053 100644 --- a/flyteadmin/pkg/async/webhook/mocks/webhook.go +++ b/flyteadmin/pkg/async/webhook/mocks/webhook.go @@ -5,9 +5,9 @@ package mocks import ( context "context" - admin "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" + admin "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - interfaces "github.com/flyteorg/flyteadmin/pkg/runtime/interfaces" + interfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" mock "github.com/stretchr/testify/mock" )