Skip to content

Commit e3309d1

Browse files
committed
Add prevent_forking_outside_group to group data source
1 parent 035265f commit e3309d1

File tree

5 files changed

+36
-27
lines changed

5 files changed

+36
-27
lines changed

docs/data-sources/group.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ data "gitlab_group" "foo" {
4545
- **name** (String) The name of this group.
4646
- **parent_id** (Number) Integer, ID of the parent group.
4747
- **path** (String) The path of the group.
48+
- **prevent_forking_outside_group** (Boolean) When enabled, users can not fork projects from this group to external namespaces
4849
- **request_access_enabled** (Boolean) Boolean, is request for access enabled to the group.
4950
- **runners_token** (String, Sensitive) The group level registration token to use during runner setup.
5051
- **visibility_level** (String) Visibility level of the group. Possible values are `private`, `internal`, `public`.

docs/resources/group.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ resource "gitlab_project" "example" {
4747
- **lfs_enabled** (Boolean) Boolean, defaults to true. Whether to enable LFS
4848
- **mentions_disabled** (Boolean) Boolean, defaults to false. Disable the capability
4949
- **parent_id** (Number) Integer, id of the parent group (creates a nested group).
50+
- **prevent_forking_outside_group** (Boolean) When enabled, users can not fork projects from this group to external namespaces
5051
- **project_creation_level** (String) , defaults to Maintainer.
5152
- **request_access_enabled** (Boolean) Boolean, defaults to false. Whether to
5253
- **require_two_factor_authentication** (Boolean) Boolean, defaults to false.

internal/provider/data_source_gitlab_group.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ var _ = registerDataSource("gitlab_group", func() *schema.Resource {
9191
Type: schema.TypeInt,
9292
Computed: true,
9393
},
94+
"prevent_forking_outside_group": {
95+
Description: "When enabled, users can not fork projects from this group to external namespaces",
96+
Type: schema.TypeBool,
97+
Computed: true,
98+
},
9499
},
95100
}
96101
})
@@ -135,6 +140,7 @@ func dataSourceGitlabGroupRead(ctx context.Context, d *schema.ResourceData, meta
135140
d.Set("parent_id", group.ParentID)
136141
d.Set("runners_token", group.RunnersToken)
137142
d.Set("default_branch_protection", group.DefaultBranchProtection)
143+
d.Set("prevent_forking_outside_group", group.PreventForkingOutsideGroup)
138144

139145
d.SetId(fmt.Sprintf("%d", group.ID))
140146

internal/provider/data_source_gitlab_group_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func testAccDataSourceGitlabGroup(src, n string) resource.TestCheckFunc {
5656
"visibility_level",
5757
"parent_id",
5858
"default_branch_protection",
59+
"prevent_forking_outside_group",
5960
}
6061

6162
for _, attribute := range testAttributes {

internal/provider/resource_gitlab_group_test.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,33 @@ func TestAccGitlabGroup_disappears(t *testing.T) {
246246
})
247247
}
248248

249+
func TestAccGitlabGroup_PreventForkingOutsideGroup(t *testing.T) {
250+
var group gitlab.Group
251+
rInt := acctest.RandInt()
252+
253+
resource.Test(t, resource.TestCase{
254+
PreCheck: func() { testAccPreCheck(t) },
255+
ProviderFactories: providerFactories,
256+
CheckDestroy: testAccCheckGitlabGroupDestroy,
257+
Steps: []resource.TestStep{
258+
{
259+
SkipFunc: isRunningInCE,
260+
Config: testAccGitlabGroupPreventForkingOutsideGroupConfig(rInt),
261+
Check: resource.ComposeTestCheckFunc(
262+
testAccCheckGitlabGroupExists("gitlab_group.foo", &group),
263+
func(s *terraform.State) error {
264+
if group.PreventForkingOutsideGroup != true {
265+
return fmt.Errorf("expected forking outside the group to be disabled")
266+
}
267+
268+
return nil
269+
},
270+
),
271+
},
272+
},
273+
})
274+
}
275+
249276
func testAccCheckGitlabGroupDisappears(group *gitlab.Group) resource.TestCheckFunc {
250277
return func(s *terraform.State) error {
251278
_, err := testGitlabClient.Groups.DeleteGroup(group.ID)
@@ -408,33 +435,6 @@ func testAccCheckGitlabGroupDestroy(s *terraform.State) error {
408435
return nil
409436
}
410437

411-
func TestAccGitlabGroup_PreventForkingOutsideGroup(t *testing.T) {
412-
var group gitlab.Group
413-
rInt := acctest.RandInt()
414-
415-
resource.Test(t, resource.TestCase{
416-
PreCheck: func() { testAccPreCheck(t) },
417-
ProviderFactories: providerFactories,
418-
CheckDestroy: testAccCheckGitlabGroupDestroy,
419-
Steps: []resource.TestStep{
420-
{
421-
SkipFunc: isRunningInCE,
422-
Config: testAccGitlabGroupPreventForkingOutsideGroupConfig(rInt),
423-
Check: resource.ComposeTestCheckFunc(
424-
testAccCheckGitlabGroupExists("gitlab_group.foo", &group),
425-
func(s *terraform.State) error {
426-
if group.PreventForkingOutsideGroup != true {
427-
return fmt.Errorf("expected forking outside the group to be disabled")
428-
}
429-
430-
return nil
431-
},
432-
),
433-
},
434-
},
435-
})
436-
}
437-
438438
func testAccGitlabGroupConfig(rInt int) string {
439439
return fmt.Sprintf(`
440440
resource "gitlab_group" "foo" {

0 commit comments

Comments
 (0)