Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Fix comments and pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
RicePatrick committed Jul 13, 2024
1 parent 7116698 commit 473bbdf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
21 changes: 12 additions & 9 deletions groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ type Group struct {
MembershipLock bool `json:"membership_lock"`
Visibility VisibilityValue `json:"visibility"`
LFSEnabled bool `json:"lfs_enabled"`
AvatarURL string `json:"avatar_url"`
DefaultBranchProtectionDefaults struct {
AllowedToPush []*GroupAccessLevel `json:"allowed_to_push"`
AllowForcePush bool `json:"allow_force_push"`
AllowedToMerge []*GroupAccessLevel `json:"allowed_to_merge"`
DeveloperCanInitialPush bool `json:"developer_can_initial_push"`
} `json:"default_branch_protection_defaults"`
AvatarURL string `json:"avatar_url"`
WebURL string `json:"web_url"`
RequestAccessEnabled bool `json:"request_access_enabled"`
RepositoryStorage string `json:"repository_storage"`
Expand Down Expand Up @@ -100,9 +100,10 @@ type Group struct {
DefaultBranchProtection int `json:"default_branch_protection"`
}

// GroupAccessLevel represents an entry in a Group defining the access level for default protections
// GroupAccessLevel represents default branch protection defaults access levels.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/groups.html#options-for-default_branch_protection_defaults
// GitLab API docs:
// https://docs.gitlab.com/ee/api/groups.html#options-for-default_branch_protection_defaults
type GroupAccessLevel struct {
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
}
Expand Down Expand Up @@ -384,14 +385,16 @@ type CreateGroupOptions struct {
DefaultBranchProtection *int `url:"default_branch_protection,omitempty" json:"default_branch_protection,omitempty"`
}

// DefaultBranchProtectionDefaultsOptions represents the available options for using default_branch_protection_defaults in CreateGroup() or UpdateGroup()
// DefaultBranchProtectionDefaultsOptions represents the available options for
// using default_branch_protection_defaults in CreateGroup() or UpdateGroup()
//
// GitLab API docs: https://docs.gitlab.com/ee/api/groups.html#options-for-default_branch_protection_defaults
// GitLab API docs:
// https://docs.gitlab.com/ee/api/groups.html#options-for-default_branch_protection_defaults
type DefaultBranchProtectionDefaultsOptions struct {
AllowedToPush []GroupAccessLevel `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"`
AllowForcePush bool `url:"allow_force_push,omitempty" json:"allow_force_push,omitempty"`
AllowedToMerge []GroupAccessLevel `url:"allowed_to_merge.omitempty" json:"allowed_to_merge.omitempty"`
DeveloperCanInitialPush bool `url:"developer_can_initial_push,omitempty" json:"developer_can_initial_push,omitempty"`
AllowedToPush *[]*GroupAccessLevel `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"`
AllowForcePush *bool `url:"allow_force_push,omitempty" json:"allow_force_push,omitempty"`
AllowedToMerge *[]*GroupAccessLevel `url:"allowed_to_merge.omitempty" json:"allowed_to_merge.omitempty"`
DeveloperCanInitialPush *bool `url:"developer_can_initial_push,omitempty" json:"developer_can_initial_push,omitempty"`
}

// CreateGroup creates a new project group. Available only for users who can
Expand Down
10 changes: 6 additions & 4 deletions groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ func TestCreateGroupDefaultBranchSettings(t *testing.T) {
Name: Ptr("g"),
Path: Ptr("g"),
DefaultBranchProtectionDefaults: &DefaultBranchProtectionDefaultsOptions{
AllowedToPush: []GroupAccessLevel{
AllowedToPush: &[]*GroupAccessLevel{
{
AccessLevel: Ptr(AccessLevelValue(40)),
},
},
AllowedToMerge: []GroupAccessLevel{
AllowedToMerge: &[]*GroupAccessLevel{
{
AccessLevel: Ptr(AccessLevelValue(40)),
},
Expand Down Expand Up @@ -174,8 +174,10 @@ func TestCreateGroupDefaultBranchSettings(t *testing.T) {
}

// Validate the request does what we want it to
assert.Equal(t, Ptr(MaintainerPermissions), jsonRequestBody.DefaultBranchProtectionDefaults.AllowedToMerge[0].AccessLevel)
assert.Equal(t, Ptr(MaintainerPermissions), jsonRequestBody.DefaultBranchProtectionDefaults.AllowedToPush[0].AccessLevel)
allowedToMerge := *jsonRequestBody.DefaultBranchProtectionDefaults.AllowedToMerge
allowedToPush := *jsonRequestBody.DefaultBranchProtectionDefaults.AllowedToPush
assert.Equal(t, Ptr(MaintainerPermissions), allowedToMerge[0].AccessLevel)
assert.Equal(t, Ptr(MaintainerPermissions), allowedToPush[0].AccessLevel)
}

func TestTransferGroup(t *testing.T) {
Expand Down

0 comments on commit 473bbdf

Please sign in to comment.