Skip to content

Commit

Permalink
Merge pull request integrations#357 from dmwgroup/integrationsgh-327-…
Browse files Browse the repository at this point in the history
…configure-repo-as-template

Gh 327 configure repo as template
  • Loading branch information
Jeremy Udit authored Apr 2, 2020
2 parents 7f33cf0 + 9588f71 commit b87caf3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func resourceGithubRepository() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"is_template": {
Type: schema.TypeBool,
Optional: true,
},
"allow_merge_commit": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -175,6 +179,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
HasIssues: github.Bool(d.Get("has_issues").(bool)),
HasProjects: github.Bool(d.Get("has_projects").(bool)),
HasWiki: github.Bool(d.Get("has_wiki").(bool)),
IsTemplate: github.Bool(d.Get("is_template").(bool)),
AllowMergeCommit: github.Bool(d.Get("allow_merge_commit").(bool)),
AllowSquashMerge: github.Bool(d.Get("allow_squash_merge").(bool)),
AllowRebaseMerge: github.Bool(d.Get("allow_rebase_merge").(bool)),
Expand Down Expand Up @@ -297,6 +302,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("has_issues", repo.HasIssues)
d.Set("has_projects", repo.HasProjects)
d.Set("has_wiki", repo.HasWiki)
d.Set("is_template", repo.IsTemplate)
d.Set("allow_merge_commit", repo.AllowMergeCommit)
d.Set("allow_squash_merge", repo.AllowSquashMerge)
d.Set("allow_rebase_merge", repo.AllowRebaseMerge)
Expand Down
8 changes: 8 additions & 0 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func TestAccGithubRepository_basic(t *testing.T) {
Homepage: "http://example.com/",
HasIssues: true,
HasWiki: true,
IsTemplate: false,
AllowMergeCommit: true,
AllowSquashMerge: false,
AllowRebaseMerge: false,
Expand All @@ -95,6 +96,7 @@ func TestAccGithubRepository_basic(t *testing.T) {
AllowMergeCommit: false,
AllowSquashMerge: true,
AllowRebaseMerge: true,
IsTemplate: true,
DefaultBranch: "master",
HasProjects: false,
Archived: false,
Expand Down Expand Up @@ -564,6 +566,7 @@ type testAccGithubRepositoryExpectedAttributes struct {
HasIssues bool
HasProjects bool
HasWiki bool
IsTemplate bool
AllowMergeCommit bool
AllowSquashMerge bool
AllowRebaseMerge bool
Expand Down Expand Up @@ -600,6 +603,9 @@ func testAccCheckGithubRepositoryAttributes(repo *github.Repository, want *testA
if *repo.HasWiki != want.HasWiki {
return fmt.Errorf("got has wiki %#v; want %#v", *repo.HasWiki, want.HasWiki)
}
if *repo.IsTemplate != want.IsTemplate {
return fmt.Errorf("got has IsTemplate %#v; want %#v", *repo.IsTemplate, want.IsTemplate)
}
if *repo.AllowMergeCommit != want.AllowMergeCommit {
return fmt.Errorf("got allow merge commit %#v; want %#v", *repo.AllowMergeCommit, want.AllowMergeCommit)
}
Expand Down Expand Up @@ -753,6 +759,7 @@ resource "github_repository" "foo" {
has_issues = true
has_wiki = true
is_template = false
allow_merge_commit = true
allow_squash_merge = false
allow_rebase_merge = false
Expand Down Expand Up @@ -784,6 +791,7 @@ resource "github_repository" "foo" {
has_issues = false
has_wiki = false
is_template = true
allow_merge_commit = false
allow_squash_merge = true
allow_rebase_merge = true
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/repository.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ The following arguments are supported:

* `has_wiki` - (Optional) Set to `true` to enable the GitHub Wiki features on
the repository.

* `is_template` - (Optional) Set to `true` to tell GitHub that this is a template repository.

* `allow_merge_commit` - (Optional) Set to `false` to disable merge commits on the repository.

Expand Down

0 comments on commit b87caf3

Please sign in to comment.