Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw committed Nov 15, 2023
1 parent 3cd0cc0 commit bcb4e89
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
20 changes: 10 additions & 10 deletions flyteadmin/pkg/async/webhook/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions flyteadmin/pkg/async/webhook/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions flyteadmin/pkg/async/webhook/implementations/processer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions flyteadmin/pkg/async/webhook/implementations/slack_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions flyteadmin/pkg/async/webhook/interfaces/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions flyteadmin/pkg/async/webhook/mocks/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions flyteadmin/pkg/async/webhook/mocks/webhook.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bcb4e89

Please sign in to comment.