Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for allow_forking on a repository/update to go-github v42 #1033

Merged
merged 7 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions github/data_source_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func dataSourceGithubRepository() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"allow_forking": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"default_branch": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -229,6 +234,7 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
d.Set("allow_forking", repo.GetAllowForking())
d.Set("has_downloads", repo.GetHasDownloads())
d.Set("full_name", repo.GetFullName())
d.Set("default_branch", repo.GetDefaultBranch())
Expand Down
7 changes: 7 additions & 0 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ func resourceGithubRepository() *schema.Resource {
Optional: true,
Default: false,
},
"allow_forking": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"delete_branch_on_merge": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -295,6 +300,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
AllowSquashMerge: github.Bool(d.Get("allow_squash_merge").(bool)),
AllowRebaseMerge: github.Bool(d.Get("allow_rebase_merge").(bool)),
AllowAutoMerge: github.Bool(d.Get("allow_auto_merge").(bool)),
AllowForking: github.Bool(d.Get("allow_forking").(bool)),
DeleteBranchOnMerge: github.Bool(d.Get("delete_branch_on_merge").(bool)),
AutoInit: github.Bool(d.Get("auto_init").(bool)),
LicenseTemplate: github.String(d.Get("license_template").(string)),
Expand Down Expand Up @@ -440,6 +446,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
d.Set("allow_forking", repo.GetAllowForking())
d.Set("delete_branch_on_merge", repo.GetDeleteBranchOnMerge())
d.Set("has_downloads", repo.GetHasDownloads())
d.Set("full_name", repo.GetFullName())
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccGithubRepositories(t *testing.T) {
allow_squash_merge = false
allow_rebase_merge = false
allow_auto_merge = true
allow_forking = false
auto_init = false

}
Expand All @@ -45,6 +46,10 @@ func TestAccGithubRepositories(t *testing.T) {
"github_repository.test", "allow_auto_merge",
"true",
),
resource.TestCheckResourceAttr(
"github_repository.test", "allow_forking",
"false",
),
)

testCase := func(t *testing.T, mode string) {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/repository.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ The following arguments are supported:

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

* `allow_forking` - Whether true to allow private forks, or false to prevent private forks.

* `has_downloads` - Whether the repository has Downloads feature enabled.

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