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

chore: do not process webhook events for private repos #1162

Merged
merged 5 commits into from
Oct 11, 2023

Conversation

rdimitrov
Copy link
Member

The following PR updates:

  • Disables processing web hook events from repositories that are now private. Covers the use case where a repository was public when it was registered, but then switched to being private.
  • Fixed an issue where we did not errored out in case creating a provider client failed while processing artifact events

Related to #1083

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

I haven't tested the PR with a private repo, leaving comment just based on reading the PR.

internal/controlplane/handlers_githubwebhooks.go Outdated Show resolved Hide resolved
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
jhrozek
jhrozek previously approved these changes Oct 11, 2023
Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

meh, I would have just did a separate if else branch for each class of error types, but this is good enough

@@ -79,6 +79,9 @@ type UpstreamRepositoryReference struct {
// ErrRepoNotFound is returned when a repository is not found
var ErrRepoNotFound = errors.New("repository not found")

// ErrRepoIsPrivate is returned when a repository is private
var ErrRepoIsPrivate = errors.New("repository is private")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of processing this as an error. In the near future we'll offer this as an enterprise feature and this route will sneak on us. Instead, let's handle it with an explicit if statement and no error for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Make sense 👍 What do you mean by having no error - revert to returning a generic error or something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I don't treat returning an error in this case as..an error..just a way to signal a condition.

Copy link
Contributor

Choose a reason for hiding this comment

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

Uhm.... as long as we don't forget later on...

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, so I've added a separate if case so it's more explicit to not forget when we remove it later 👍

@rdimitrov
Copy link
Member Author

meh, I would have just did a separate if else branch for each class of error types, but this is good enough

Thought of that, but since we don't do a lot of special things based on the error types I did not wanted to expand visually that section too much

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

I like this version

@rdimitrov rdimitrov merged commit 8d08d8b into mindersec:main Oct 11, 2023
12 checks passed
@rdimitrov rdimitrov deleted the no-private-webhook branch October 11, 2023 08:21
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.

3 participants