diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index d9a6b6dfe6..91aa5371e3 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -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, @@ -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)), @@ -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) diff --git a/github/resource_github_repository_test.go b/github/resource_github_repository_test.go index a4bed6f120..960004df12 100644 --- a/github/resource_github_repository_test.go +++ b/github/resource_github_repository_test.go @@ -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, @@ -95,6 +96,7 @@ func TestAccGithubRepository_basic(t *testing.T) { AllowMergeCommit: false, AllowSquashMerge: true, AllowRebaseMerge: true, + IsTemplate: true, DefaultBranch: "master", HasProjects: false, Archived: false, @@ -564,6 +566,7 @@ type testAccGithubRepositoryExpectedAttributes struct { HasIssues bool HasProjects bool HasWiki bool + IsTemplate bool AllowMergeCommit bool AllowSquashMerge bool AllowRebaseMerge bool @@ -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) } @@ -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 @@ -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 diff --git a/website/docs/r/repository.html.markdown b/website/docs/r/repository.html.markdown index cf65a3bf79..76d550c601 100644 --- a/website/docs/r/repository.html.markdown +++ b/website/docs/r/repository.html.markdown @@ -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.