Skip to content

Commit

Permalink
Rename variable skip_team_creation (#38)
Browse files Browse the repository at this point in the history
Suggested fix for #32
  • Loading branch information
ryancheley committed Aug 18, 2024
2 parents 5ccf3b3 + e2da756 commit 4121224
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ repositories = {
template = "" # optional, default is ""
topics = []
visibility = "public" # optional, default is "public"
skip_team_creation = optional(bool, false) # Do not create teams for repository
is_django_commons_repo = optional(bool, false) # Do not create teams for repository
enable_branch_protection = true # optional, default is true
required_status_checks_contexts = [] # optional, default is []
admins = [] # Members of the repository's admin and repository teams. Have admin permissions
Expand Down
2 changes: 1 addition & 1 deletion terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ All changes should be made in `production/*.tfvars`:
template = "" # optional, default is ""
topics = []
visibility = "public" # optional, default is "public"
skip_team_creation = optional(bool, false) # Do not create teams for repository
is_django_commons_repo = optional(bool, false) # Do not create teams for repository
enable_branch_protection = true # optional, default is true
required_status_checks_contexts = [] # optional, default is []
admins = [] # Members of the repository's admin and repository teams. Have admin permissions
Expand Down
24 changes: 12 additions & 12 deletions terraform/production/repositories.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ repositories = {
description = "A Special Repository."
enable_branch_protection = false

topics = []
push_allowances = []
skip_team_creation = true
topics = []
push_allowances = []
is_django_commons_repo = true
}

"controls" = {
Expand All @@ -19,18 +19,18 @@ repositories = {
allow_squash_merge = true
topics = []
push_allowances = []
skip_team_creation = true
is_django_commons_repo = true
}

"membership" = {
description = "Membership repository for the django-commons organization."
visibility = "public"
allow_merge_commit = true
allow_rebase_merge = true
allow_squash_merge = true
topics = []
push_allowances = []
skip_team_creation = true
description = "Membership repository for the django-commons organization."
visibility = "public"
allow_merge_commit = true
allow_rebase_merge = true
allow_squash_merge = true
topics = []
push_allowances = []
is_django_commons_repo = true
}

"django-commons-playground" = {
Expand Down
6 changes: 3 additions & 3 deletions terraform/resources-repo-admin-teams.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Define the admin team for each repository
resource "github_team" "repo_admin_team" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }

parent_team_id = github_team.repo_team[each.key].id
name = "${each.key}-admins"
Expand All @@ -10,7 +10,7 @@ resource "github_team" "repo_admin_team" {

# Add the people to the team
resource "github_team_members" "repo_admin_members" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }

team_id = github_team.repo_admin_team[each.key].id

Expand All @@ -26,7 +26,7 @@ resource "github_team_members" "repo_admin_members" {

# Define the team's permissions for the repositories
resource "github_team_repository" "repo_admin_team_access" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }
repository = each.key
team_id = github_team.repo_admin_team[each.key].id
permission = "admin"
Expand Down
6 changes: 3 additions & 3 deletions terraform/resources-repo-committer-teams.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Define the committers team for each repository
resource "github_team" "repo_committer_team" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }

parent_team_id = github_team.repo_team[each.key].id
name = "${each.key}-committers"
Expand All @@ -12,7 +12,7 @@ resource "github_team" "repo_committer_team" {
resource "github_team_members" "repo_committer_team_members" {
for_each = {
for k, v in var.repositories : k => v
if v.skip_team_creation == false && length(v.committers) > 0
if v.is_django_commons_repo == false && length(v.committers) > 0
}

team_id = github_team.repo_committer_team[each.key].id
Expand All @@ -31,7 +31,7 @@ resource "github_team_members" "repo_committer_team_members" {
resource "github_team_repository" "repo_committer_team_access" {
for_each = {
for k, v in var.repositories : k => v
if v.skip_team_creation == false
if v.is_django_commons_repo == false
}
repository = each.key
team_id = github_team.repo_committer_team[each.key].id
Expand Down
8 changes: 4 additions & 4 deletions terraform/resources-repo-teams.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Create the main repository team for Django Commons.
resource "github_team" "repo_team" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }

name = each.key
description = "Main team for the ${each.key} repository"
privacy = "closed"
}
# Add the people to the team
resource "github_team_members" "repo_team_members" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }

team_id = github_team.repo_team[each.key].id

Expand All @@ -27,7 +27,7 @@ resource "github_team_members" "repo_team_members" {
}
# Define the team's permissions for the repositories
resource "github_team_repository" "repo_team_access" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }
repository = each.key
team_id = github_team.repo_team[each.key].id
permission = "triage"
Expand All @@ -37,7 +37,7 @@ resource "github_team_repository" "repo_team_access" {

# This is used to enable automatic PR review requests
resource "github_team_settings" "this" {
for_each = { for k, v in var.repositories : k => v if v.skip_team_creation == false }
for_each = { for k, v in var.repositories : k => v if v.is_django_commons_repo == false }

review_request_delegation {
algorithm = "LOAD_BALANCE"
Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ variable "repositories" {
template = optional(string)
topics = optional(list(string))
visibility = optional(string, "public")
skip_team_creation = optional(bool, false) # Do not create teams for repository
is_django_commons_repo = optional(bool, false) # Do not create teams for repository
admins = optional(set(string), []) # Members of the repository's admin and repository teams. Have admin permissions
committers = optional(set(string), [])
# Members of the repository's committers and repository teams. Have write permissions
Expand Down

0 comments on commit 4121224

Please sign in to comment.