Skip to content

Modeling User.Permissions as struct instead of map[string]bool #3947

@Not-Dhananjay-Mishra

Description

@Not-Dhananjay-Mishra

Similar to #3934
According to the List Collaborators Docs, the permissions object has a fixed, well-defined structure:

{
  "permissions": {
    "type": "object",
    "properties": {
      "pull": {
        "type": "boolean"
      },
      "triage": {
        "type": "boolean"
      },
      "push": {
        "type": "boolean"
      },
      "maintain": {
        "type": "boolean"
      },
      "admin": {
        "type": "boolean"
      }
    }
  }
}

Currently it is typed as map[string]bool (It was added in 2015 so I guess it is safe to update):

// Permissions and RoleName identify the permissions and role that a user has on a given
// repository. These are only populated when calling Repositories.ListCollaborators.
Permissions map[string]bool `json:"permissions,omitempty"`
RoleName *string `json:"role_name,omitempty"`

we can use RepositoryPermissions struct introduced in #3936

Metadata

Metadata

Assignees

Labels

Breaking API ChangePR will require a bump to the major version num in next release. Look here to see the change(s).enhancementgood first issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions