From 63c97e6b532f62c65ffa14f28724fb0c4648874c Mon Sep 17 00:00:00 2001 From: Felix Luthman <34520175+felixlut@users.noreply.github.com> Date: Sun, 22 Sep 2024 23:13:36 +0200 Subject: [PATCH] feat: Support baseRole option for custom organization roles (#3284) Fixes: #3283. --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/orgs_custom_roles.go | 1 + 3 files changed, 19 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index a99a06aa314..a025f781faf 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4414,6 +4414,14 @@ func (c *CreateOrUpdateCustomRepoRoleOptions) GetName() string { return *c.Name } +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (c *CreateOrUpdateOrgRoleOptions) GetBaseRole() string { + if c == nil || c.BaseRole == nil { + return "" + } + return *c.BaseRole +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (c *CreateOrUpdateOrgRoleOptions) GetDescription() string { if c == nil || c.Description == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 2db51bab3dd..ae380160dc7 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -5179,6 +5179,16 @@ func TestCreateOrUpdateCustomRepoRoleOptions_GetName(tt *testing.T) { c.GetName() } +func TestCreateOrUpdateOrgRoleOptions_GetBaseRole(tt *testing.T) { + var zeroValue string + c := &CreateOrUpdateOrgRoleOptions{BaseRole: &zeroValue} + c.GetBaseRole() + c = &CreateOrUpdateOrgRoleOptions{} + c.GetBaseRole() + c = nil + c.GetBaseRole() +} + func TestCreateOrUpdateOrgRoleOptions_GetDescription(tt *testing.T) { var zeroValue string c := &CreateOrUpdateOrgRoleOptions{Description: &zeroValue} diff --git a/github/orgs_custom_roles.go b/github/orgs_custom_roles.go index ca0c6d7bcba..086c4a824f0 100644 --- a/github/orgs_custom_roles.go +++ b/github/orgs_custom_roles.go @@ -54,6 +54,7 @@ type CreateOrUpdateOrgRoleOptions struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` Permissions []string `json:"permissions"` + BaseRole *string `json:"base_role,omitempty"` } // CreateOrUpdateCustomRepoRoleOptions represents options required to create or update a custom repository role.