From 448cf7b21cc978297767e4ba2b2297126b63f9e5 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 2 Jun 2021 13:40:29 -0400 Subject: [PATCH 1/2] [PERMISSIONS-SUPPORT] :sparkles: Add support for maintain and triage repositories permissions --- README.md | 20 +++++++++++++++----- main.tf | 10 ++++++---- variables.tf | 12 ++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 32ca6f0..949a45b 100644 --- a/README.md +++ b/README.md @@ -94,11 +94,26 @@ See [variables.tf] and [examples/] for details and use-cases. The name of the team. +- **`admin_repositories`**: _(Optional `set(string)`)_ + + A list of repository names the current team should get admin (full) permission to. + Default is `[]`. + +- **`maintain_repositories`**: _(Optional `set(string)`)_ + + A list of repository names the current team should get admin (maintain) permission to. + Default is `[]`. + - **`push_repositories`**: _(Optional `set(string)`)_ A list of repository names the current team should get push (read-write) permission to. Default is `[]`. +- **`triage_repositories`**: _(Optional `set(string)`)_ + + A list of repository names the current team should get push (triage) permission to. + Default is `[]`. + - **`pull_repositories`**: _(Optional `set(string)`)_ A list of repository names the current team should get pull (read-only) permission to. @@ -114,11 +129,6 @@ See [variables.tf] and [examples/] for details and use-cases. A list of users that will be added to the current team with member permissions. Default is `[]`. -- **`admin_repositories`**: _(Optional `set(string)`)_ - - A list of repository names the current team should get admin (full) permission to. - Default is `[]`. - - **`description`**: _(Optional `string`)_ A description of the team. diff --git a/main.tf b/main.tf index 1a1385d..7f22d0a 100644 --- a/main.tf +++ b/main.tf @@ -36,11 +36,13 @@ resource "github_team_membership" "team_membership" { } locals { - repo_admin = { for i in var.admin_repositories : lower(i) => { permission = "admin", repository = i } } - repo_push = { for i in var.push_repositories : lower(i) => { permission = "push", repository = i } } - repo_pull = { for i in var.pull_repositories : lower(i) => { permission = "pull", repository = i } } + repo_admin = { for i in var.admin_repositories : lower(i) => { permission = "admin", repository = i } } + repo_maintain = { for i in var.admin_repositories : lower(i) => { permission = "maintain", repository = i } } + repo_push = { for i in var.push_repositories : lower(i) => { permission = "push", repository = i } } + repo_triage = { for i in var.push_repositories : lower(i) => { permission = "triage", repository = i } } + repo_pull = { for i in var.pull_repositories : lower(i) => { permission = "pull", repository = i } } - repositories = merge(local.repo_admin, local.repo_push, local.repo_pull) + repositories = merge(local.repo_admin, local.repo_admin, local.repo_push, local.repo_triage, local.repo_pull) } resource "github_team_repository" "team_repository" { diff --git a/variables.tf b/variables.tf index 7c82253..81e7f28 100644 --- a/variables.tf +++ b/variables.tf @@ -63,12 +63,24 @@ variable "admin_repositories" { default = [] } +variable "maintain_repositories" { + description = "(Optional) A list of repository names the current team should get push (maintain) permission to." + type = set(string) + default = [] +} + variable "push_repositories" { description = "(Optional) A list of repository names the current team should get push (read-write) permission to." type = set(string) default = [] } +variable "triage_repositories" { + description = "(Optional) A list of repository names the current team should get push (triage) permission to." + type = set(string) + default = [] +} + variable "pull_repositories" { description = "(Optional) A list of repository names the current team should get pull (read-only) permission to." type = set(string) From 5372861f593ac155d02f3cf7e53048e7bf1906f5 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 2 Jun 2021 19:54:37 -0400 Subject: [PATCH 2/2] [PERMISSIONS-SUPPORT] :sparkles: fix typo, code review comments --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 7f22d0a..bd81690 100644 --- a/main.tf +++ b/main.tf @@ -42,7 +42,7 @@ locals { repo_triage = { for i in var.push_repositories : lower(i) => { permission = "triage", repository = i } } repo_pull = { for i in var.pull_repositories : lower(i) => { permission = "pull", repository = i } } - repositories = merge(local.repo_admin, local.repo_admin, local.repo_push, local.repo_triage, local.repo_pull) + repositories = merge(local.repo_admin, local.repo_maintain, local.repo_push, local.repo_triage, local.repo_pull) } resource "github_team_repository" "team_repository" {