Skip to content

Fix handleKindGitHub, Change FindSyncWebhook

Administrator requested to merge deleteFind into main

Created by: susantoscott

Fix a problem from previous PR where we were returning too early (return when a webhook was found in config). We will always call FindSyncWebhook to look for the webhook from GitHub API to determine whether we want to create a new webhook. In the process, we store the webhook in the extsvc Config.

TODO: maybe we should store the fact that a repo has a sync webhook so we don't have to call FindSyncWebhook every time a job is dequeued (or everytime an external service is synced). This might be in the form of a boolean attribute on a repo, or storing this repo-webhook pair in the database somewhere.

Also in this PR is changing the FindSyncWebhook method to return the complete payload from GitHub instead of just the webhook ID. This is so we can get the secret from the WebhookPayload Config and add it into the extsvc Config

Test plan

go test -run TestWebhookBuildHandle

Merge request reports

Loading