Repository: google/go-github
Pull request #3184 (2024-06-11 09:44:58)

Add fields to the InstallationPermissions struct
Added the fields:
- actions_variables
- organization_custom_org_roles

They were missing from the permissions map


Patch:
diff --git a/github/apps.go b/github/apps.go
index 6969daba..16ef758c 100644
--- a/github/apps.go
+++ b/github/apps.go
@@ -78,6 +78,7 @@ type InstallationTokenListRepoOptions struct {
 //	https://docs.github.com/rest/apps#create-an-installation-access-token-for-an-app
 type InstallationPermissions struct {
 	Actions                       *string `json:"actions,omitempty"`
+	ActionsVariables              *string `json:"actions_variables,omitempty"`
 	Administration                *string `json:"administration,omitempty"`
 	Blocking                      *string `json:"blocking,omitempty"`
 	Checks                        *string `json:"checks,omitempty"`
@@ -93,6 +94,7 @@ type InstallationPermissions struct {
 	OrganizationAdministration    *string `json:"organization_administration,omitempty"`
 	OrganizationCustomProperties  *string `json:"organization_custom_properties,omitempty"`
 	OrganizationCustomRoles       *string `json:"organization_custom_roles,omitempty"`
+	OrganizationCustomOrgRoles    *string `json:"organization_custom_org_roles,omitempty"`
 	OrganizationHooks             *string `json:"organization_hooks,omitempty"`
 	OrganizationPackages          *string `json:"organization_packages,omitempty"`
 	OrganizationPlan              *string `json:"organization_plan,omitempty"`
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 421922d3..98985def 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -8822,6 +8822,14 @@ func (i *InstallationPermissions) GetActions() string {
 	return *i.Actions
 }
 
+// GetActionsVariables returns the ActionsVariables field if it's non-nil, zero value otherwise.
+func (i *InstallationPermissions) GetActionsVariables() string {
+	if i == nil || i.ActionsVariables == nil {
+		return ""
+	}
+	return *i.ActionsVariables
+}
+
 // GetAdministration returns the Administration field if it's non-nil, zero value otherwise.
 func (i *InstallationPermissions) GetAdministration() string {
 	if i == nil || i.Administration == nil {
@@ -8926,6 +8934,14 @@ func (i *InstallationPermissions) GetOrganizationAdministration() string {
 	return *i.OrganizationAdministration
 }
 
+// GetOrganizationCustomOrgRoles returns the OrganizationCustomOrgRoles field if it's non-nil, zero value otherwise.
+func (i *InstallationPermissions) GetOrganizationCustomOrgRoles() string {
+	if i == nil || i.OrganizationCustomOrgRoles == nil {
+		return ""
+	}
+	return *i.OrganizationCustomOrgRoles
+}
+
 // GetOrganizationCustomProperties returns the OrganizationCustomProperties field if it's non-nil, zero value otherwise.
 func (i *InstallationPermissions) GetOrganizationCustomProperties() string {
 	if i == nil || i.OrganizationCustomProperties == nil {
diff --git a/github/repos_contents.go b/github/repos_contents.go
index c4453739..97539aee 100644
--- a/github/repos_contents.go
+++ b/github/repos_contents.go
@@ -150,7 +150,11 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo,
 				return nil, resp, fmt.Errorf("no download link found for %s", filepath)
 			}
 
-			dlResp, err := s.client.client.Get(*contents.DownloadURL)
+			dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil)
+			if err != nil {
+				return nil, resp, err
+			}
+			dlResp, err := s.client.client.Do(dlReq)
 			if err != nil {
 				return nil, &Response{Response: dlResp}, err
 			}
@@ -188,7 +192,11 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne
 				return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath)
 			}
 
-			dlResp, err := s.client.client.Get(*contents.DownloadURL)
+			dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil)
+			if err != nil {
+				return nil, contents, resp, err
+			}
+			dlResp, err := s.client.client.Do(dlReq)
 			if err != nil {
 				return nil, contents, &Response{Response: dlResp}, err
 			}


Test patch:
diff --git a/github/apps_test.go b/github/apps_test.go
index ea670344..bb060d7a 100644
--- a/github/apps_test.go
+++ b/github/apps_test.go
@@ -769,6 +769,7 @@ func TestInstallationPermissions_Marshal(t *testing.T) {
 		Metadata:                      String("md"),
 		Members:                       String("m"),
 		OrganizationAdministration:    String("oa"),
+		OrganizationCustomOrgRoles:    String("ocr"),
 		OrganizationHooks:             String("oh"),
 		OrganizationPlan:              String("op"),
 		OrganizationPreReceiveHooks:   String("opr"),
@@ -804,6 +805,7 @@ func TestInstallationPermissions_Marshal(t *testing.T) {
 		"metadata": "md",
 		"members": "m",
 		"organization_administration": "oa",
+		"organization_custom_org_roles": "ocr",
 		"organization_hooks": "oh",
 		"organization_plan": "op",
 		"organization_pre_receive_hooks": "opr",
@@ -869,6 +871,7 @@ func TestInstallation_Marshal(t *testing.T) {
 		SingleFilePaths:     []string{"s"},
 		Permissions: &InstallationPermissions{
 			Actions:                       String("a"),
+			ActionsVariables:              String("ac"),
 			Administration:                String("ad"),
 			Checks:                        String("c"),
 			Contents:                      String("co"),
@@ -879,6 +882,7 @@ func TestInstallation_Marshal(t *testing.T) {
 			Metadata:                      String("md"),
 			Members:                       String("m"),
 			OrganizationAdministration:    String("oa"),
+			OrganizationCustomOrgRoles:    String("ocr"),
 			OrganizationHooks:             String("oh"),
 			OrganizationPlan:              String("op"),
 			OrganizationPreReceiveHooks:   String("opr"),
@@ -967,6 +971,7 @@ func TestInstallation_Marshal(t *testing.T) {
 		],
 		"permissions": {
 			"actions": "a",
+			"actions_variables": "ac",
 			"administration": "ad",
 			"checks": "c",
 			"contents": "co",
@@ -977,6 +982,7 @@ func TestInstallation_Marshal(t *testing.T) {
 			"metadata": "md",
 			"members": "m",
 			"organization_administration": "oa",
+			"organization_custom_org_roles": "ocr",
 			"organization_hooks": "oh",
 			"organization_plan": "op",
 			"organization_pre_receive_hooks": "opr",
@@ -1035,6 +1041,7 @@ func TestInstallationTokenOptions_Marshal(t *testing.T) {
 		RepositoryIDs: []int64{1},
 		Permissions: &InstallationPermissions{
 			Actions:                       String("a"),
+			ActionsVariables:              String("ac"),
 			Administration:                String("ad"),
 			Checks:                        String("c"),
 			Contents:                      String("co"),
@@ -1045,6 +1052,7 @@ func TestInstallationTokenOptions_Marshal(t *testing.T) {
 			Metadata:                      String("md"),
 			Members:                       String("m"),
 			OrganizationAdministration:    String("oa"),
+			OrganizationCustomOrgRoles:    String("ocr"),
 			OrganizationHooks:             String("oh"),
 			OrganizationPlan:              String("op"),
 			OrganizationPreReceiveHooks:   String("opr"),
@@ -1073,6 +1081,7 @@ func TestInstallationTokenOptions_Marshal(t *testing.T) {
 		"repository_ids": [1],
 		"permissions": {
 			"actions": "a",
+			"actions_variables": "ac",
 			"administration": "ad",
 			"checks": "c",
 			"contents": "co",
@@ -1083,6 +1092,7 @@ func TestInstallationTokenOptions_Marshal(t *testing.T) {
 			"metadata": "md",
 			"members": "m",
 			"organization_administration": "oa",
+			"organization_custom_org_roles": "ocr",
 			"organization_hooks": "oh",
 			"organization_plan": "op",
 			"organization_pre_receive_hooks": "opr",
@@ -1118,6 +1128,7 @@ func TestInstallationToken_Marshal(t *testing.T) {
 		ExpiresAt: &Timestamp{referenceTime},
 		Permissions: &InstallationPermissions{
 			Actions:                       String("a"),
+			ActionsVariables:              String("ac"),
 			Administration:                String("ad"),
 			Checks:                        String("c"),
 			Contents:                      String("co"),
@@ -1128,6 +1139,7 @@ func TestInstallationToken_Marshal(t *testing.T) {
 			Metadata:                      String("md"),
 			Members:                       String("m"),
 			OrganizationAdministration:    String("oa"),
+			OrganizationCustomOrgRoles:    String("ocr"),
 			OrganizationHooks:             String("oh"),
 			OrganizationPlan:              String("op"),
 			OrganizationPreReceiveHooks:   String("opr"),
@@ -1164,6 +1176,7 @@ func TestInstallationToken_Marshal(t *testing.T) {
 		"expires_at": ` + referenceTimeStr + `,
 		"permissions": {
 			"actions": "a",
+			"actions_variables": "ac",
 			"administration": "ad",
 			"checks": "c",
 			"contents": "co",
@@ -1174,6 +1187,7 @@ func TestInstallationToken_Marshal(t *testing.T) {
 			"metadata": "md",
 			"members": "m",
 			"organization_administration": "oa",
+			"organization_custom_org_roles": "ocr",
 			"organization_hooks": "oh",
 			"organization_plan": "op",
 			"organization_pre_receive_hooks": "opr",
@@ -1243,6 +1257,7 @@ func TestApp_Marshal(t *testing.T) {
 		UpdatedAt:   &Timestamp{referenceTime},
 		Permissions: &InstallationPermissions{
 			Actions:                       String("a"),
+			ActionsVariables:              String("ac"),
 			Administration:                String("ad"),
 			Checks:                        String("c"),
 			Contents:                      String("co"),
@@ -1253,6 +1268,7 @@ func TestApp_Marshal(t *testing.T) {
 			Metadata:                      String("md"),
 			Members:                       String("m"),
 			OrganizationAdministration:    String("oa"),
+			OrganizationCustomOrgRoles:    String("ocr"),
 			OrganizationHooks:             String("oh"),
 			OrganizationPlan:              String("op"),
 			OrganizationPreReceiveHooks:   String("opr"),
@@ -1310,6 +1326,7 @@ func TestApp_Marshal(t *testing.T) {
 		"updated_at": ` + referenceTimeStr + `,
 		"permissions": {
 			"actions": "a",
+			"actions_variables": "ac",
 			"administration": "ad",
 			"checks": "c",
 			"contents": "co",
@@ -1320,6 +1337,7 @@ func TestApp_Marshal(t *testing.T) {
 			"metadata": "md",
 			"members": "m",
 			"organization_administration": "oa",
+			"organization_custom_org_roles": "ocr",
 			"organization_hooks": "oh",
 			"organization_plan": "op",
 			"organization_pre_receive_hooks": "opr",
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 8753c42b..f123be8f 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -10338,6 +10338,16 @@ func TestInstallationPermissions_GetActions(tt *testing.T) {
 	i.GetActions()
 }
 
+func TestInstallationPermissions_GetActionsVariables(tt *testing.T) {
+	var zeroValue string
+	i := &InstallationPermissions{ActionsVariables: &zeroValue}
+	i.GetActionsVariables()
+	i = &InstallationPermissions{}
+	i.GetActionsVariables()
+	i = nil
+	i.GetActionsVariables()
+}
+
 func TestInstallationPermissions_GetAdministration(tt *testing.T) {
 	var zeroValue string
 	i := &InstallationPermissions{Administration: &zeroValue}
@@ -10468,6 +10478,16 @@ func TestInstallationPermissions_GetOrganizationAdministration(tt *testing.T) {
 	i.GetOrganizationAdministration()
 }
 
+func TestInstallationPermissions_GetOrganizationCustomOrgRoles(tt *testing.T) {
+	var zeroValue string
+	i := &InstallationPermissions{OrganizationCustomOrgRoles: &zeroValue}
+	i.GetOrganizationCustomOrgRoles()
+	i = &InstallationPermissions{}
+	i.GetOrganizationCustomOrgRoles()
+	i = nil
+	i.GetOrganizationCustomOrgRoles()
+}
+
 func TestInstallationPermissions_GetOrganizationCustomProperties(tt *testing.T) {
 	var zeroValue string
 	i := &InstallationPermissions{OrganizationCustomProperties: &zeroValue}