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: Implement organization role assignments for both users and teams #3281

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

Conversation

felixlut
Copy link
Contributor

resolves #3280

@felixlut
Copy link
Contributor Author

felixlut commented Sep 21, 2024

While working on this I noticed that the file naming is slightly off from how GitHub structures their API:s. There's a difference between repository roles and organization roles, but currently the orgs_custom_roles.go file is dealing with both (even before my changes). It should probably be split up into orgs_repo_roles.go and orgs_org_roles.go (or maybe flip the order to orgs_role_{org/repo}.go to keep the files "closer together"), similarily to integrations/terraform-provider-github#2224.

Leaving it up to the reviewer to decide if this should be done in this PR directly or in a separate one later

@gmlewis gmlewis changed the title feat: implement organization role assignments for both users and teams feat: Implement organization role assignments for both users and teams Sep 21, 2024
@gmlewis
Copy link
Collaborator

gmlewis commented Sep 21, 2024

Leaving it up to the reviewer to decide if this should be done in this PR directly or in a separate one later

Please perform the reorganization in your next PR. Thank you!

Copy link

codecov bot commented Sep 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.96%. Comparing base (2b8c7fa) to head (00a67d2).
Report is 116 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3281      +/-   ##
==========================================
- Coverage   97.72%   92.96%   -4.76%     
==========================================
  Files         153      171      +18     
  Lines       13390    11705    -1685     
==========================================
- Hits        13085    10882    -2203     
- Misses        215      729     +514     
- Partials       90       94       +4     

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

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @felixlut !
Just a few minor tweaks, please, then we should be ready for a second LGTM+Approval from any other contributor to this repo.

// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-team
//
//meta:operation PUT /orgs/{org}/organization-roles/teams/{team_slug}/{role_id}
func (s *OrganizationsService) AssignOrgRoleToTeam(ctx context.Context, org string, teamSlug string, roleID int64) (*Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (s *OrganizationsService) AssignOrgRoleToTeam(ctx context.Context, org string, teamSlug string, roleID int64) (*Response, error) {
func (s *OrganizationsService) AssignOrgRoleToTeam(ctx context.Context, org, teamSlug string, roleID int64) (*Response, error) {

// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-team
//
//meta:operation DELETE /orgs/{org}/organization-roles/teams/{team_slug}/{role_id}
func (s *OrganizationsService) RemoveOrgRoleFromTeam(ctx context.Context, org string, teamSlug string, roleID int64) (*Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (s *OrganizationsService) RemoveOrgRoleFromTeam(ctx context.Context, org string, teamSlug string, roleID int64) (*Response, error) {
func (s *OrganizationsService) RemoveOrgRoleFromTeam(ctx context.Context, org, teamSlug string, roleID int64) (*Response, error) {

// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-user
//
//meta:operation PUT /orgs/{org}/organization-roles/users/{username}/{role_id}
func (s *OrganizationsService) AssignOrgRoleToUser(ctx context.Context, org string, username string, roleID int64) (*Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (s *OrganizationsService) AssignOrgRoleToUser(ctx context.Context, org string, username string, roleID int64) (*Response, error) {
func (s *OrganizationsService) AssignOrgRoleToUser(ctx context.Context, org, username string, roleID int64) (*Response, error) {

return resp, nil
}

// RemoveOrgRoleFromUser removes an existing organization role assignment to a user in this organization.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// RemoveOrgRoleFromUser removes an existing organization role assignment to a user in this organization.
// RemoveOrgRoleFromUser removes an existing organization role assignment from a user in this organization.

return resp, nil
}

// RemoveOrgRoleFromTeam removes an existing organization role assignment to a team in this organization.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// RemoveOrgRoleFromTeam removes an existing organization role assignment to a team in this organization.
// RemoveOrgRoleFromTeam removes an existing organization role assignment from a team in this organization.

// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-user
//
//meta:operation DELETE /orgs/{org}/organization-roles/users/{username}/{role_id}
func (s *OrganizationsService) RemoveOrgRoleFromUser(ctx context.Context, org string, username string, roleID int64) (*Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (s *OrganizationsService) RemoveOrgRoleFromUser(ctx context.Context, org string, username string, roleID int64) (*Response, error) {
func (s *OrganizationsService) RemoveOrgRoleFromUser(ctx context.Context, org, username string, roleID int64) (*Response, error) {

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsReview PR is awaiting a review before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Support assigning organization roles to teams and users
2 participants