From a31a4a100f082dc61f6d03e13d7815ed125e54c8 Mon Sep 17 00:00:00 2001 From: Ben F Date: Fri, 14 Feb 2020 13:49:12 +0000 Subject: [PATCH 1/2] GH-327 - Added is_template field to resource --- github/resource_github_repository.go | 6 ++++++ github/resource_github_repository_test.go | 8 ++++++++ website/docs/r/repository.html.markdown | 2 ++ 3 files changed, 16 insertions(+) diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index a0a9929d29..a978785a58 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, @@ -170,6 +174,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)), @@ -291,6 +296,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 3ca4fabda7..63e389785a 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, @@ -94,6 +95,7 @@ func TestAccGithubRepository_basic(t *testing.T) { AllowMergeCommit: false, AllowSquashMerge: true, AllowRebaseMerge: true, + IsTemplate: true, DefaultBranch: "master", HasProjects: false, Archived: false, @@ -563,6 +565,7 @@ type testAccGithubRepositoryExpectedAttributes struct { HasIssues bool HasProjects bool HasWiki bool + IsTemplate bool AllowMergeCommit bool AllowSquashMerge bool AllowRebaseMerge bool @@ -598,6 +601,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) } @@ -751,6 +757,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 @@ -782,6 +789,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 5447db65be..65934cde1b 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. From add6d6decc61b0dff92da4f8718463e5fae3e27b Mon Sep 17 00:00:00 2001 From: Ben F Date: Fri, 14 Feb 2020 14:05:20 +0000 Subject: [PATCH 2/2] GH-327 - formatting fix GH-327 - Formatting fix --- github/resource_github_repository.go | 4 ++-- github/resource_github_repository_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index a978785a58..eb5661511c 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -61,7 +61,7 @@ func resourceGithubRepository() *schema.Resource { Optional: true, }, "is_template": { - Type: schema.TypeBool, + Type: schema.TypeBool, Optional: true, }, "allow_merge_commit": { @@ -174,7 +174,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)), + 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)), diff --git a/github/resource_github_repository_test.go b/github/resource_github_repository_test.go index 63e389785a..0c4c01e2d1 100644 --- a/github/resource_github_repository_test.go +++ b/github/resource_github_repository_test.go @@ -73,7 +73,7 @@ func TestAccGithubRepository_basic(t *testing.T) { Homepage: "http://example.com/", HasIssues: true, HasWiki: true, - IsTemplate: false, + IsTemplate: false, AllowMergeCommit: true, AllowSquashMerge: false, AllowRebaseMerge: false, @@ -565,7 +565,7 @@ type testAccGithubRepositoryExpectedAttributes struct { HasIssues bool HasProjects bool HasWiki bool - IsTemplate bool + IsTemplate bool AllowMergeCommit bool AllowSquashMerge bool AllowRebaseMerge bool @@ -757,7 +757,7 @@ resource "github_repository" "foo" { has_issues = true has_wiki = true - is_template = false + is_template = false allow_merge_commit = true allow_squash_merge = false allow_rebase_merge = false