-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Example For
github_team_repository
(#676)
* Add Example For `github_team_repository` also documents a limitation with `for_each` in this scenario * fixup! add newline
- Loading branch information
Jeremy Udit
authored
Jan 27, 2021
1 parent
54371c9
commit ad5dffb
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Repository Team Example | ||
|
||
This demos populating a repository with a team. | ||
|
||
This example will create a repositories in the specified `owner` organization. See https://www.terraform.io/docs/providers/github/index.html for details on configuring [`providers.tf`](./providers.tf) accordingly. | ||
|
||
Alternatively, you may use variables passed via command line: | ||
|
||
```console | ||
export GITHUB_OWNER= | ||
export GITHUB_TOKEN= | ||
``` | ||
|
||
```console | ||
terraform apply \ | ||
-var "owner=${GITHUB_OWNER}" \ | ||
-var "github_token=${GITHUB_TOKEN}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# NOTE: There are errors when using the following syntax. See links for details. | ||
# /cc https://github.com/hashicorp/terraform/issues/23529 | ||
# /cc https://github.com/hashicorp/terraform/issues/4149 | ||
# /cc https://github.com/integrations/terraform-provider-github/issues/500 | ||
# | ||
# data "github_team" "writers" { | ||
# slug = "writer-team" | ||
# } | ||
# | ||
# resource "github_team_repository" "writers" { | ||
# for_each = data.github_team.writers.id | ||
# # or for multiple teams something like: | ||
# # for_each = { for obj in [data.github_team.writers] : obj.id => obj.id } | ||
# team_id = each.value | ||
# repository = "repo" | ||
# permission = "push" | ||
# } | ||
|
||
data "github_team" "writers" { | ||
slug = "writers" | ||
} | ||
|
||
data "github_team" "editors" { | ||
slug = "editors" | ||
} | ||
|
||
locals { | ||
teams = [data.github_team.writers.id, data.github_team.editors.id] | ||
} | ||
|
||
resource "github_repository" "writers" { | ||
name = "writers" | ||
auto_init = true | ||
} | ||
|
||
resource "github_team_repository" "writers" { | ||
count = length(local.teams) | ||
team_id = local.teams[count.index] | ||
repository = github_repository.writers.name | ||
permission = "push" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider "github" { | ||
owner = var.owner | ||
token = var.github_token | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "owner" { | ||
description = "GitHub owner used to configure the provider" | ||
type = string | ||
} | ||
|
||
variable "github_token" { | ||
description = "GitHub access token used to configure the provider" | ||
type = string | ||
} |