Skip to content

Commit

Permalink
fix(webhooks): remove unused workflows field
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen committed Jun 27, 2024
1 parent 31cf5be commit 4f42c5f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
15 changes: 7 additions & 8 deletions internal/services/webhooks/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,13 @@ func (c *WebhooksController) run(tenantId string, webhookWorker *dbsqlc.WebhookW
}

ww, err := webhook.New(webhook.WorkerOpts{
Token: token,
ID: id,
Secret: secret,
URL: webhookWorker.Url,
Name: webhookWorker.Name,
TenantID: tenantId,
Actions: h.Actions,
Workflows: h.Workflows,
Token: token,
ID: id,
Secret: secret,
URL: webhookWorker.Url,
Name: webhookWorker.Name,
TenantID: tenantId,
Actions: h.Actions,
})
if err != nil {
return nil, fmt.Errorf("could not create webhook worker: %w", err)
Expand Down
17 changes: 8 additions & 9 deletions pkg/webhook/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ type WebhookWorker struct {
}

type WorkerOpts struct {
Name string
Token string
ID string
Secret string
URL string
TenantID string
Actions []string
Workflows []string
Name string
Token string
ID string
Secret string
URL string
TenantID string
Actions []string
}

func New(opts WorkerOpts) (*WebhookWorker, error) {
Expand All @@ -40,7 +39,7 @@ func New(opts WorkerOpts) (*WebhookWorker, error) {
func (w *WebhookWorker) Start() (func() error, error) {
r, err := worker.NewWorker(
worker.WithClient(w.client),
worker.WithInternalData(w.opts.Actions, w.opts.Workflows),
worker.WithInternalData(w.opts.Actions),
worker.WithName("Webhook_"+w.opts.ID),
)
if err != nil {
Expand Down
7 changes: 2 additions & 5 deletions pkg/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ type WorkerOpts struct {
alerter errors.Alerter
maxRuns *int

actions []string
workflows []string
actions []string
}

func defaultWorkerOpts() *WorkerOpts {
Expand All @@ -128,10 +127,9 @@ func WithLogLevel(lvl string) WorkerOpt {
}
}

func WithInternalData(actions []string, workflows []string) WorkerOpt {
func WithInternalData(actions []string) WorkerOpt {
return func(opts *WorkerOpts) {
opts.actions = actions
opts.workflows = workflows
}
}

Expand Down Expand Up @@ -184,7 +182,6 @@ func NewWorker(fs ...WorkerOpt) (*Worker, error) {
middlewares: mws,
maxRuns: opts.maxRuns,
initActionNames: opts.actions,
workflows: opts.workflows,
}

mws.add(w.panicMiddleware)
Expand Down

0 comments on commit 4f42c5f

Please sign in to comment.