Repository: google/go-github
Pull request #2452 (2022-09-06 23:02:42)

InstallationPermissions: organization perms
Adds `organization_custom_roles` and `organization_packages` as available permissions on the `InstallPermissions` struct, per https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app


I've functionally tested the `organization_custom_roles` bit, but I'm not sure how to verify `organization_packages`. It is documented online and in other libraries like octokit: https://github.com/search?q=org%3Aoctokit+organization_packages&type=code , but I can't add it to a test GitHub.com app. It may only be available on GitHub Enterprise? 🤷 

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2452?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2452](https://codecov.io/gh/google/go-github/pull/2452?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (663def3) into [master](https://codecov.io/gh/google/go-github/commit/e8cac35caf11500112c6a67c302de07dfd5ef112?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (e8cac35) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##           master    #2452   +/-   ##
=======================================
  Coverage   98.03%   98.03%           
=======================================
  Files         122      122           
  Lines       10689    10689           
=======================================
  Hits        10479    10479           
  Misses        144      144           
  Partials       66       66           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2452?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/apps.go](https://codecov.io/gh/google/go-github/pull/2452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2FwcHMuZ28=) | `95.16% <ø> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)


Patch:
diff --git a/github/apps.go b/github/apps.go
index 0e92f7b7..98d8a6fd 100644
--- a/github/apps.go
+++ b/github/apps.go
@@ -77,7 +77,9 @@ type InstallationPermissions struct {
 	Metadata                      *string `json:"metadata,omitempty"`
 	Members                       *string `json:"members,omitempty"`
 	OrganizationAdministration    *string `json:"organization_administration,omitempty"`
+	OrganizationCustomRoles       *string `json:"organization_custom_roles,omitempty"`
 	OrganizationHooks             *string `json:"organization_hooks,omitempty"`
+	OrganizationPackages          *string `json:"organization_packages,omitempty"`
 	OrganizationPlan              *string `json:"organization_plan,omitempty"`
 	OrganizationPreReceiveHooks   *string `json:"organization_pre_receive_hooks,omitempty"`
 	OrganizationProjects          *string `json:"organization_projects,omitempty"`
diff --git a/github/github-accessors.go b/github/github-accessors.go
index e30f5bea..32074e27 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -6590,6 +6590,14 @@ func (i *InstallationPermissions) GetOrganizationAdministration() string {
 	return *i.OrganizationAdministration
 }
 
+// GetOrganizationCustomRoles returns the OrganizationCustomRoles field if it's non-nil, zero value otherwise.
+func (i *InstallationPermissions) GetOrganizationCustomRoles() string {
+	if i == nil || i.OrganizationCustomRoles == nil {
+		return ""
+	}
+	return *i.OrganizationCustomRoles
+}
+
 // GetOrganizationHooks returns the OrganizationHooks field if it's non-nil, zero value otherwise.
 func (i *InstallationPermissions) GetOrganizationHooks() string {
 	if i == nil || i.OrganizationHooks == nil {
@@ -6598,6 +6606,14 @@ func (i *InstallationPermissions) GetOrganizationHooks() string {
 	return *i.OrganizationHooks
 }
 
+// GetOrganizationPackages returns the OrganizationPackages field if it's non-nil, zero value otherwise.
+func (i *InstallationPermissions) GetOrganizationPackages() string {
+	if i == nil || i.OrganizationPackages == nil {
+		return ""
+	}
+	return *i.OrganizationPackages
+}
+
 // GetOrganizationPlan returns the OrganizationPlan field if it's non-nil, zero value otherwise.
 func (i *InstallationPermissions) GetOrganizationPlan() string {
 	if i == nil || i.OrganizationPlan == nil {


Test patch:
diff --git a/github/apps_test.go b/github/apps_test.go
index e003e278..494f1031 100644
--- a/github/apps_test.go
+++ b/github/apps_test.go
@@ -99,7 +99,9 @@ func TestAppsService_ListInstallations(t *testing.T) {
                                        "metadata": "read",
                                        "members": "read",
                                        "organization_administration": "write",
+                                       "organization_custom_roles": "write",
                                        "organization_hooks": "write",
+                                       "organization_packages": "write",
                                        "organization_plan": "read",
                                        "organization_pre_receive_hooks": "write",
                                        "organization_projects": "read",
@@ -159,7 +161,9 @@ func TestAppsService_ListInstallations(t *testing.T) {
 			Metadata:                      String("read"),
 			Members:                       String("read"),
 			OrganizationAdministration:    String("write"),
+			OrganizationCustomRoles:       String("write"),
 			OrganizationHooks:             String("write"),
+			OrganizationPackages:          String("write"),
 			OrganizationPlan:              String("read"),
 			OrganizationPreReceiveHooks:   String("write"),
 			OrganizationProjects:          String("read"),
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index a48ca939..5296ee96 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -7734,6 +7734,16 @@ func TestInstallationPermissions_GetOrganizationAdministration(tt *testing.T) {
 	i.GetOrganizationAdministration()
 }
 
+func TestInstallationPermissions_GetOrganizationCustomRoles(tt *testing.T) {
+	var zeroValue string
+	i := &InstallationPermissions{OrganizationCustomRoles: &zeroValue}
+	i.GetOrganizationCustomRoles()
+	i = &InstallationPermissions{}
+	i.GetOrganizationCustomRoles()
+	i = nil
+	i.GetOrganizationCustomRoles()
+}
+
 func TestInstallationPermissions_GetOrganizationHooks(tt *testing.T) {
 	var zeroValue string
 	i := &InstallationPermissions{OrganizationHooks: &zeroValue}
@@ -7744,6 +7754,16 @@ func TestInstallationPermissions_GetOrganizationHooks(tt *testing.T) {
 	i.GetOrganizationHooks()
 }
 
+func TestInstallationPermissions_GetOrganizationPackages(tt *testing.T) {
+	var zeroValue string
+	i := &InstallationPermissions{OrganizationPackages: &zeroValue}
+	i.GetOrganizationPackages()
+	i = &InstallationPermissions{}
+	i.GetOrganizationPackages()
+	i = nil
+	i.GetOrganizationPackages()
+}
+
 func TestInstallationPermissions_GetOrganizationPlan(tt *testing.T) {
 	var zeroValue string
 	i := &InstallationPermissions{OrganizationPlan: &zeroValue}