diff --git a/README.md b/README.md index 29807b2..1e19938 100644 --- a/README.md +++ b/README.md @@ -155,21 +155,40 @@ The GitHub organization YAML configuration post a Terraform plan as a pull reque ```yaml --- default-properties: # OPTIONAL - visibility: public # OPTIONAL - has_issues: true # OPTIONAL - has_discussions: true # OPTIONAL - has_projects: true # OPTIONAL - has_wiki: true # OPTIONAL + # Global properties + visibility: public # OPTIONAL, DEFAULT public + # Global features + has_issues: true # OPTIONAL, DEFAULT false + has_discussions: true # OPTIONAL, DEFAULT false + has_projects: true # OPTIONAL, DEFAULT false + has_wiki: true # OPTIONAL, DEFAULT false + # Global settings + allow_merge_commit: false # OPTIONAL, DEFAULT true + allow_squash_merge: true # OPTIONAL, DEFAULT true + allow_rebase_merge: true # OPTIONAL, DEFAULT true + allow_auto_merge: true # OPTIONAL, DEFAULT false + delete_branch_on_merge: true # OPTIONAL, DEFAULT false repositories: - name: repo-slug - description: Repository description. # OPTIONAL - topics: # OPTIONAL + # Repository metadata + description: Repository description. # OPTIONAL, DEFAULT none + homepage_url: http://repo.domain/ # OPTIONAL, DEFAULT none + topics: # OPTIONAL, DEFAULT none - github-topic-1 - visibility: public # OPTIONAL - has_issues: true # OPTIONAL - has_discussions: true # OPTIONAL - has_projects: true # OPTIONAL - has_wiki: true # OPTIONAL + # Repository properties + visibility: public # OPTIONAL, DEFAULT public + is_template: true # OPTIONAL, DEFAULT false + # Repository features + has_issues: true # OPTIONAL, DEFAULT false + has_discussions: true # OPTIONAL, DEFAULT false + has_projects: true # OPTIONAL, DEFAULT false + has_wiki: true # OPTIONAL, DEFAULT false + # Repository settings + allow_merge_commit: false # OPTIONAL, DEFAULT true + allow_squash_merge: true # OPTIONAL, DEFAULT true + allow_rebase_merge: true # OPTIONAL, DEFAULT true + allow_auto_merge: true # OPTIONAL, DEFAULT false + delete_branch_on_merge: true # OPTIONAL, DEFAULT false ``` Defaults are the same as in the Terraform provider `github` resource `github_repository`, see [Terraform Registry / Providers / integrations / github / resources / github_repository](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository#argument-reference). diff --git a/main.tf b/main.tf index 14fc353..6c83c7d 100644 --- a/main.tf +++ b/main.tf @@ -6,13 +6,27 @@ locals { resource "github_repository" "repo" { for_each = { for repo in local.repositories : repo.name => repo } - name = each.value.name - description = try(each.value.description, null) - topics = try(each.value.topics, null) - visibility = try(each.value.visibility, local.default_properties.visibility, null) + # Metadata + name = each.value.name + description = try(each.value.description, null) + homepage_url = try(each.value.homepage_url, null) + topics = try(each.value.topics, null) + + # Properties + visibility = try(each.value.visibility, local.default_properties.visibility, null) + is_template = try(each.value.is_template, null) + + # Features has_issues = try(each.value.has_issues, local.default_properties.has_issues, null) has_discussions = try(each.value.has_discussions, local.default_properties.has_discussions, null) has_projects = try(each.value.has_projects, local.default_properties.has_projects, null) has_wiki = try(each.value.has_wiki, local.default_properties.has_wiki, null) + + # Settings + allow_merge_commit = try(each.value.allow_merge_commit, local.default_properties.allow_merge_commit, null) + allow_squash_merge = try(each.value.allow_squash_merge, local.default_properties.allow_squash_merge, null) + allow_rebase_merge = try(each.value.allow_rebase_merge, local.default_properties.allow_rebase_merge, null) + allow_auto_merge = try(each.value.allow_auto_merge, local.default_properties.allow_auto_merge, null) + delete_branch_on_merge = try(each.value.delete_branch_on_merge, local.default_properties.delete_branch_on_merge, null) } diff --git a/test.yaml b/test.yaml index 2714171..1e5de7f 100644 --- a/test.yaml +++ b/test.yaml @@ -1,8 +1,18 @@ --- +default-properties: + # Global features + has_issues: true repositories: - name: .github + # Repository metadata description: Xebis Test organization profile. topics: - github-organization-profile - github-profile - github-profile-readme + # Repository settings + allow_merge_commit: false + allow_squash_merge: true + allow_rebase_merge: true + allow_auto_merge: true + delete_branch_on_merge: true