Skip to content

Commit

Permalink
Merge pull request #38 from PavelSusloparov/feature/permissions-suppo…
Browse files Browse the repository at this point in the history
…rt-triage-maintain

[PERMISSIONS-SUPPORT] ✨ Add support for maintain and triage repositories permissions
  • Loading branch information
soerenmartius authored Jun 3, 2021
2 parents 95cc73b + 5372861 commit baf531a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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_maintain, local.repo_push, local.repo_triage, local.repo_pull)
}

resource "github_team_repository" "team_repository" {
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit baf531a

Please sign in to comment.