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

Support outside collaborators in owners check #197

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bobertrublik
Copy link

Description

Changes proposed in this pull request:

  • add an outsideCollaborators map
  • add initOutsideCollaboratorsList() function to fill outsideCollaborators map
  • additionally check in validateGitHubUser() whether a given username is an outside collaborator

Related issue(s)

@bobertrublik bobertrublik changed the title Support outside collaborators to owners check Support outside collaborators in owners check Apr 24, 2023
@mszostok mszostok self-assigned this May 6, 2023
Copy link
Owner

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

I have only two small comments, besides that it's a really good job 🚀

@@ -48,6 +48,7 @@ type ValidOwner struct {
orgName string
orgTeams []*github.Team
orgRepoName string
outsideCollaborators *map[string]struct{}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
outsideCollaborators *map[string]struct{}
outsideCollaborators map[string]struct{}

FYI: We don't use pointers for map. Map is already a reference type, so it does not make sens here. To learn more, see:
https://go.dev/blog/maps

return newValidateError("User %q is not a member of the organization", name)
_, isOutsideCollaborator := (*v.outsideCollaborators)[userName]
if !(isMember || isOutsideCollaborator) {
return newValidateError("User %q is not an owner of the repository", name)
Copy link
Owner

Choose a reason for hiding this comment

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

owner in the context of the repository means a bit more 🙂

Suggested change
return newValidateError("User %q is not an owner of the repository", name)
return newValidateError("The user %q is neither a collaborator nor a member of this repository.", name)

opt.Page = resp.NextPage
}

v.outsideCollaborators = &map[string]struct{}{}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
v.outsideCollaborators = &map[string]struct{}{}
v.outsideCollaborators = map[string]struct{}{}

@bobertrublik bobertrublik force-pushed the support-outside-collaborators branch from 413a776 to 46700ad Compare May 24, 2023 19:31
@bobertrublik
Copy link
Author

I applied your suggestions! :) Sorry for taking so long, I've been sick for the last two weeks.

PS: I guess it would have a made more sense to apply the changes in new commits instead of modifying the original commit.

@mszostok mszostok added the enhancement New feature or request label Jun 5, 2023
Copy link
Owner

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

Awesome work! Thanks for your contribution 🙇

@bobertrublik
Copy link
Author

Thank you for approving. :) Is the error in the integration test caused by my changes?

@infinisil
Copy link

I just opened #222 which I believe would be a better fix for this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants