Skip to content

Commit 76e03fb

Browse files
diogopmskfcampbell
andauthored
Support for allow_forking on a repository/update to go-github v42 (integrations#1033)
* updating go-github to v42 * support for allow_forking field * Make allow_forking optional; default to true * Default allow_forking to true in resource Co-authored-by: Keegan Campbell <me@kfcampbell.com>
1 parent 8f64901 commit 76e03fb

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

github/data_source_github_repository.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ func dataSourceGithubRepository() *schema.Resource {
7979
Type: schema.TypeBool,
8080
Computed: true,
8181
},
82+
"allow_forking": {
83+
Type: schema.TypeBool,
84+
Optional: true,
85+
Default: true,
86+
},
8287
"default_branch": {
8388
Type: schema.TypeString,
8489
Computed: true,
@@ -229,6 +234,7 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
229234
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
230235
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
231236
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
237+
d.Set("allow_forking", repo.GetAllowForking())
232238
d.Set("has_downloads", repo.GetHasDownloads())
233239
d.Set("full_name", repo.GetFullName())
234240
d.Set("default_branch", repo.GetDefaultBranch())

github/resource_github_repository.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ func resourceGithubRepository() *schema.Resource {
9494
Optional: true,
9595
Default: false,
9696
},
97+
"allow_forking": {
98+
Type: schema.TypeBool,
99+
Optional: true,
100+
Default: true,
101+
},
97102
"delete_branch_on_merge": {
98103
Type: schema.TypeBool,
99104
Optional: true,
@@ -295,6 +300,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
295300
AllowSquashMerge: github.Bool(d.Get("allow_squash_merge").(bool)),
296301
AllowRebaseMerge: github.Bool(d.Get("allow_rebase_merge").(bool)),
297302
AllowAutoMerge: github.Bool(d.Get("allow_auto_merge").(bool)),
303+
AllowForking: github.Bool(d.Get("allow_forking").(bool)),
298304
DeleteBranchOnMerge: github.Bool(d.Get("delete_branch_on_merge").(bool)),
299305
AutoInit: github.Bool(d.Get("auto_init").(bool)),
300306
LicenseTemplate: github.String(d.Get("license_template").(string)),
@@ -440,6 +446,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
440446
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
441447
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
442448
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
449+
d.Set("allow_forking", repo.GetAllowForking())
443450
d.Set("delete_branch_on_merge", repo.GetDeleteBranchOnMerge())
444451
d.Set("has_downloads", repo.GetHasDownloads())
445452
d.Set("full_name", repo.GetFullName())

github/resource_github_repository_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestAccGithubRepositories(t *testing.T) {
3131
allow_squash_merge = false
3232
allow_rebase_merge = false
3333
allow_auto_merge = true
34+
allow_forking = false
3435
auto_init = false
3536
3637
}
@@ -45,6 +46,10 @@ func TestAccGithubRepositories(t *testing.T) {
4546
"github_repository.test", "allow_auto_merge",
4647
"true",
4748
),
49+
resource.TestCheckResourceAttr(
50+
"github_repository.test", "allow_forking",
51+
"false",
52+
),
4853
)
4954

5055
testCase := func(t *testing.T, mode string) {

website/docs/d/repository.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ The following arguments are supported:
5151

5252
* `allow_auto_merge` - Whether the repository allows auto-merging pull requests.
5353

54+
* `allow_forking` - Whether true to allow private forks, or false to prevent private forks.
55+
5456
* `has_downloads` - Whether the repository has Downloads feature enabled.
5557

5658
* `default_branch` - The name of the default branch of the repository.

0 commit comments

Comments
 (0)