+
Skip to content

Add missing permissions to InstallationPermissions #1180

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

Merged
merged 3 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions github/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,36 @@ type InstallationToken struct {
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

// InstallationPermissions lists the permissions for metadata, contents, issues and single file for an installation.
// InstallationPermissions lists the repository and organization permissions for an installation.
//
// Permission names taken from:
// https://developer.github.com/v3/apps/permissions/
// https://developer.github.com/enterprise/v3/apps/permissions/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

type InstallationPermissions struct {
Metadata *string `json:"metadata,omitempty"`
Contents *string `json:"contents,omitempty"`
Issues *string `json:"issues,omitempty"`
SingleFile *string `json:"single_file,omitempty"`
Administration *string `json:"administration,omitempty"`
Checks *string `json:"checks,omitempty"`
Contents *string `json:"contents,omitempty"`
ContentReferences *string `json:"content_references,omitempty"`
Deployments *string `json:"deployments,omitempty"`
Issues *string `json:"issues,omitempty"`
Metadata *string `json:"metadata,omitempty"`

Choose a reason for hiding this comment

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

According to the following documentation:
https://developer.github.com/apps/building-github-apps/creating-github-apps-using-url-parameters/#github-app-permissions

It seems like this should be RepositoryMetadata, and more importantly, the JSON key should be repository_metadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@itsdalmo that seems to be an error in the docs, the key from the response is definitely metadata.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, @itsdalmo and @tarebyte!

Would one of you please volunteer to contact support@github.com and let them know about the documentation error? They are typically very responsive, friendly, and helpful, and this would be appreciated feedback. Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would one of you please volunteer to contact support@github.com and let them know about the documentation error?

I can file an internal issue, I work for GitHub 😃

They are typically very responsive, friendly, and helpful, and this would be appreciated feedback. Thank you!

💖

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, uh, Wow! I'm humbled and honored that you are helping us out here, @tarebyte!!!

You and your team have been an absolute joy to work with! I have a bunch of virtual friends at GitHub Tech Support. Thanks for all you do!

So let's see... all I need is another LGTM and we are good to merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, uh, Wow! I'm humbled and honored that you are helping us out here, @tarebyte!!!

You and your team have been an absolute joy to work with! I have a bunch of virtual friends at GitHub Tech Support. Thanks for all you do!

It's my pleasure! Thank you for working on such a ✨ library

Members *string `json:"members,omitempty"`
OrganizationAdministration *string `json:"organization_administration,omitempty"`
OrganizationHooks *string `json:"organization_hooks,omitempty"`
OrganizationPlan *string `json:"organization_plan,omitempty"`
OrganizationPreReceiveHooks *string `json:"organization_pre_receive_hooks,omitempty"`
OrganizationProjects *string `json:"organization_projects,omitempty"`
OrganizationUserBlocking *string `json:"organization_user_blocking,omitempty"`
Packages *string `json:"packages,omitempty"`
Pages *string `json:"pages,omitempty"`
PullRequests *string `json:"pull_requests,omitempty"`
RepositoryHooks *string `json:"repository_hooks,omitempty"`
RepositoryProjects *string `json:"repository_projects,omitempty"`
RepositoryPreReceiveHooks *string `json:"repository_pre_receive_hooks,omitempty"`
SingleFile *string `json:"single_file,omitempty"`
Statuses *string `json:"statuses,omitempty"`
TeamDiscussions *string `json:"team_discussions,omitempty"`
VulnerabilityAlerts *string `json:"vulnerability_alerts,omitempty"`
}

// Installation represents a GitHub Apps installation.
Expand Down
52 changes: 46 additions & 6 deletions github/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,30 @@ func TestAppsService_ListInstallations(t *testing.T) {
"target_id":1,
"target_type": "Organization",
"permissions": {
"metadata": "read",
"administration": "read",
"checks": "read",
"contents": "read",
"content_references": "read",
"deployments": "read",
"issues": "write",
"single_file": "write"
"metadata": "read",
"members": "read",
"organization_administration": "write",
"organization_hooks": "write",
"organization_plan": "read",
"organization_pre_receive_hooks": "write",
"organization_projects": "read",
"organization_user_blocking": "write",
"packages": "read",
"pages": "read",
"pull_requests": "write",
"repository_hooks": "write",
"repository_projects": "read",
"repository_pre_receive_hooks": "read",
"single_file": "write",
"statuses": "write",
"team_discussions": "read",
"vulnerability_alerts": "read"
},
"events": [
"push",
Expand Down Expand Up @@ -104,10 +124,30 @@ func TestAppsService_ListInstallations(t *testing.T) {
SingleFileName: String("config.yml"),
RepositorySelection: String("selected"),
Permissions: &InstallationPermissions{
Metadata: String("read"),
Contents: String("read"),
Issues: String("write"),
SingleFile: String("write")},
Administration: String("read"),
Checks: String("read"),
Contents: String("read"),
ContentReferences: String("read"),
Deployments: String("read"),
Issues: String("write"),
Metadata: String("read"),
Members: String("read"),
OrganizationAdministration: String("write"),
OrganizationHooks: String("write"),
OrganizationPlan: String("read"),
OrganizationPreReceiveHooks: String("write"),
OrganizationProjects: String("read"),
OrganizationUserBlocking: String("write"),
Packages: String("read"),
Pages: String("read"),
PullRequests: String("write"),
RepositoryHooks: String("write"),
RepositoryProjects: String("read"),
RepositoryPreReceiveHooks: String("read"),
SingleFile: String("write"),
Statuses: String("write"),
TeamDiscussions: String("read"),
VulnerabilityAlerts: String("read")},
Events: []string{"push", "pull_request"},
CreatedAt: &date,
UpdatedAt: &date,
Expand Down
160 changes: 160 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载