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
Teams.IsTeamRepoByID support for custom roles #2378
Comments
Based on the API documentation you linked above, I don't see any other option but to include the Although this does indeed seem strange, what alternatives can you think of? |
I wondered if this function should really return a e.g. type TeamRepositoryPermissions struct {
Permissions map[string]bool `json:"permissions,omitempty"`
RoleName *string `json:"role_name,omitempty"`
} But understand that would be a breaking change so maybe not ideal. |
Looking at the example response here: https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-repository 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 I'd also like to include the below function in // GetRoleName returns the role_name field if it's non-nil, zero value otherwise.
func (r *Repository) GetRoleName() string {
if r == nil || r.RoleName == nil {
return ""
}
return *r.RoleName
} If you agree, I'll raise a PR sometime today. |
Yes, go ahead with a PR but do not manually edit the accessors file as it is autogenerated. Please read CONTRIBUTING.md for details. |
Ahh, I see. Thanks 😃 . PR is here whenever you get a second. |
Thankyou @gmlewis! Any idea when your next release will be? |
Right now: https://github.com/google/go-github/releases/tag/v45.1.0 |
Amazing! Thankyou |
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.
https://github.com/google/go-github/blob/master/github/teams.go#L411L427
Currently, we return a
repository
object, which contains information about whichpermissions
the specifiedteam
has on the repository.e.g.
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
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.e.g.
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 therole_name
? It seems a bit strange to me that thepermissions
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 includerole_name
make sense?The text was updated successfully, but these errors were encountered: