-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: main
Are you sure you want to change the base?
Support outside collaborators in owners check #197
Conversation
There was a problem hiding this 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 🚀
internal/check/valid_owner.go
Outdated
@@ -48,6 +48,7 @@ type ValidOwner struct { | |||
orgName string | |||
orgTeams []*github.Team | |||
orgRepoName string | |||
outsideCollaborators *map[string]struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
internal/check/valid_owner.go
Outdated
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) |
There was a problem hiding this comment.
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 🙂
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) |
internal/check/valid_owner.go
Outdated
opt.Page = resp.NextPage | ||
} | ||
|
||
v.outsideCollaborators = &map[string]struct{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v.outsideCollaborators = &map[string]struct{}{} | |
v.outsideCollaborators = map[string]struct{}{} |
413a776
to
46700ad
Compare
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. |
There was a problem hiding this 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 🙇
Thank you for approving. :) Is the error in the integration test caused by my changes? |
I just opened #222 which I believe would be a better fix for this :) |
Description
Changes proposed in this pull request:
outsideCollaborators
mapinitOutsideCollaboratorsList()
function to filloutsideCollaborators
mapvalidateGitHubUser()
whether a given username is an outside collaboratorRelated issue(s)