Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add webhook_secret column to repos #28

Merged
merged 3 commits into from
Jul 28, 2023
Merged

Conversation

scott-codecov
Copy link
Contributor

Instead of a globally configured webhook secret for GitLab we'll store a unique secret per repo. This PR adds a new repos.webhook_secret column to store that secret.

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Merging #28 (06f4cd2) into main (566ea83) will decrease coverage by 0.06%.
The diff coverage is 72.72%.

@@           Coverage Diff           @@
##            main     #28     +/-   ##
=======================================
- Coverage   95.26   95.20   -0.06     
=======================================
  Files        569     570      +1     
  Lines      14291   14317     +26     
=======================================
+ Hits       13613   13630     +17     
- Misses       678     687      +9     
Flag Coverage Δ
unit 95.20% <72.72%> (-0.06%) ⬇️
unit-latest-uploader 95.20% <72.72%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
utils/migrations.py 47.82% <55.55%> (+0.83%) ⬆️
core/management/commands/update_gitlab_webhooks.py 80.55% <58.33%> (-12.04%) ⬇️
core/migrations/0028_repository_webhook_secret.py 100.00% <100.00%> (ø)
core/models.py 97.44% <100.00%> (+0.01%) ⬆️
webhook_handlers/views/gitlab.py 96.89% <100.00%> (+0.04%) ⬆️

@@ -20,7 +21,7 @@ def add_arguments(self, parser: CommandParser) -> None:

def handle(self, *args, **options):
repos = Repository.objects.filter(
Q(author__service="gitlab") & ~Q(hookid=None),
Q(author__service="gitlab") & ~Q(hookid=None) & Q(webhook_secret=None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need/want to rely on hookid? Are we deprecating that eventually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we'll continue using that field. It stores the external ID of the webhook installed in the Git provider's repo. We need that ID to make any updates to the webhook.

Copy link
Contributor

@adrian-codecov adrian-codecov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good here

@hootener
Copy link

hootener commented Jul 27, 2023

Codecov Report

Patch coverage: 72.72% and project coverage change: -0.06% ⚠️

Comparison is base (566ea83) 95.25% compared to head (06f4cd2) 95.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
- Coverage   95.25%   95.20%   -0.06%     
==========================================
  Files         569      570       +1     
  Lines       14291    14317      +26     
==========================================
+ Hits        13613    13630      +17     
- Misses        678      687       +9     
Flag Coverage Δ
unit 95.20% <72.72%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
utils/migrations.py 47.82% <55.55%> (+0.83%) ⬆️
core/management/commands/update_gitlab_webhooks.py 80.55% <58.33%> (-12.04%) ⬇️
core/migrations/0028_repository_webhook_secret.py 100.00% <100.00%> (ø)
core/models.py 97.44% <100.00%> (+0.01%) ⬆️
webhook_handlers/views/gitlab.py 96.89% <100.00%> (+0.04%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@scott-codecov scott-codecov merged commit 54bde93 into main Jul 28, 2023
7 of 10 checks passed
@scott-codecov scott-codecov deleted the scott/webhook-secrets branch July 28, 2023 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants