You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Teams.IsTeamRepoByID support for custom roles #2378
Now that GitHub has created the custom roles feature, I think the implementation of Teams.IsTeamRepoByID (and BySlug) may need to be changed, or a new function added.
However, the API that we interact with here also returns the name of the role that is assigned to that team on that repository.
e.g
"role_name": "admin"
Previously this was not an issue, as it was possible to work out what the role name would be based on the permissions object. (since all role names are included there.) Now that custom roles are available, a role based on the admin role may be created, but with a custom name.
Based on what is returned from this function currently, we cannot get the name of the role, and the permissions object looks identical to the one returned when the built-in admin role is assigned.
Should we extend the Repository type to include the role_name? It seems a bit strange to me that the permissions object is included there since that describes an assignment between a team and a repo rather than just an attribute of the repo. But if we wanted to follow that pattern would the change to include role_name make sense?
Based on the API documentation you linked above, I don't see any other option but to include the role_name into the Repository struct, with a comment that it is returned only for certain API endpoints.
Although this does indeed seem strange, what alternatives can you think of?
I wondered if this function should really return a Repository struct at all? Since we're checking what permissions a specific team has on a specific repository, should we create/use a new struct like TeamRepositoryPermissions.
For some reason, the GitHub v3 API team decided that all that information needed to be returned, so I don't think we want to discard the vast majority of it.
OK sure, understood. That being the case I guess we have no choice but to include role_name in the exiting repository struct?
I'd also like to include the below function in github-accessors.go:
// GetRoleName returns the role_name field if it's non-nil, zero value otherwise.func (r*Repository) GetRoleName() string {
ifr==nil||r.RoleName==nil {
return""
}
return*r.RoleName
}
Activity
gmlewis commentedon Jun 6, 2022
Based on the API documentation you linked above, I don't see any other option but to include the
role_nameinto theRepositorystruct, with a comment that it is returned only for certain API endpoints.Although this does indeed seem strange, what alternatives can you think of?
joshua-hancox commentedon Jun 6, 2022
I wondered if this function should really return a
Repositorystruct at all? Since we're checking what permissions a specific team has on a specific repository, should we create/use a new struct likeTeamRepositoryPermissions.e.g.
But understand that would be a breaking change so maybe not ideal.
gmlewis commentedon Jun 6, 2022
Looking at the example response here: https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-repository
I don't see how we cannot return a
Repositorystruct.For some reason, the GitHub v3 API team decided that all that information needed to be returned, so I don't think we want to discard the vast majority of it.
joshua-hancox commentedon Jun 7, 2022
OK sure, understood. That being the case I guess we have no choice but to include
role_namein the exitingrepositorystruct?I'd also like to include the below function in
github-accessors.go:If you agree, I'll raise a PR sometime today.
gmlewis commentedon Jun 7, 2022
Yes, go ahead with a PR but do not manually edit the accessors file as it is autogenerated. Please read CONTRIBUTING.md for details.
joshua-hancox commentedon Jun 7, 2022
Ahh, I see. Thanks 😃 .
PR is here whenever you get a second.
#2379
joshua-hancox commentedon Jun 7, 2022
Thankyou @gmlewis! Any idea when your next release will be?
gmlewis commentedon Jun 7, 2022
Right now: https://github.com/google/go-github/releases/tag/v45.1.0
😄
joshua-hancox commentedon Jun 7, 2022
Amazing! Thankyou
Include RoleName field in Repository struct (google#2379)
Include RoleName field in Repository struct (google#2379)