Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ for details and use-cases.

#### Top-level Arguments

##### Module Configuration
- **`module_depends_on`**: *(Optional `list(any)`)*
Due to the fact, that terraform does not offer `depends_on` on modules as of today (v0.12.24)
we might hit race conditions when dealing with team names instead of ids.
So when using the feature of [adding teams by slug/name](#teams-configuration) to the repository when creating it,
make sure to add all teams to this list as indirect dependencies.
Default is `[]`.

##### Repository Configuration
- **`name`**: ***(Required `string`)***
The name of the repository.
Expand Down Expand Up @@ -186,6 +194,9 @@ Teams need to exist beforehand. Your can use non-computed
(`*_teams` Attributes; **recommended**)
or computed (only known in `terraform apply` phase) team IDs
(`*_team_ids` Attributes).
When using non-computed names/slugs make sure to add the actual team resources as
indirect dependencies in `module_depends_on` as explained in
[Module Configuration](#module-configuration) above.

- **`pull_teams`** or **`pull_team_ids`**: *(Optional `list(string)`)*
A list of teams to grant pull (read-only) permission.
Expand Down Expand Up @@ -449,11 +460,11 @@ The following attributes are exported by the module:
- **`repository`**: All repository attributes as returned by the
[`github_repository` resource](https://www.terraform.io/docs/providers/github/r/repository.html#attributes-reference)
containing all arguments as specified above and the other attributes as specified below.
- **`full_name`**: A string of the form "orgname/reponame".
- **`html_url`**: URL to the repository on the web.
- **`ssh_clone_url`**: URL that can be provided to git clone to clone the repository via SSH.
- **`http_clone_url`**: URL that can be provided to git clone to clone the repository via HTTPS.
- **`git_clone_url`**: URL that can be provided to git clone to clone the repository anonymously via the git protocol.
- **`full_name`**: A string of the form "orgname/reponame".
- **`html_url`**: URL to the repository on the web.
- **`ssh_clone_url`**: URL that can be provided to git clone to clone the repository via SSH.
- **`http_clone_url`**: URL that can be provided to git clone to clone the repository via HTTPS.
- **`git_clone_url`**: URL that can be provided to git clone to clone the repository anonymously via the git protocol.

- **`collaborators`**: A map of Collaborator objects keyed by the `name` of the collaborator as returned by the
[`github_repository_collaborator` resource](https://www.terraform.io/docs/providers/github/r/repository_collaborator.html#attribute-reference).
Expand Down
14 changes: 6 additions & 8 deletions examples/private-repository-with-team/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@
# ---------------------------------------------------------------------------------------------------------------------
# SET TERRAFORM AND PROVIDER REQUIREMENTS FOR RUNNING THIS MODULE
# ---------------------------------------------------------------------------------------------------------------------

terraform {
required_version = ">= 0.12.9"

required_providers {
github = ">= 2.3.1, < 3.0.0"
}
provider "github" {
version = "~> 2.6"
}


module "repository" {
source = "../.."

module_depends_on = [
github_team.team
]

name = var.name
description = var.description
homepage_url = var.homepage_url
Expand Down
20 changes: 5 additions & 15 deletions examples/public-repository-complete-example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,12 @@
# settings. Also we create a single team and attach it to one of the repositories.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ---------------------------------------------------------------------------------------------------------------------
# TERRAFORM
# We need at least version 0.12.9 for full for_each functionality
# ---------------------------------------------------------------------------------------------------------------------

terraform {
required_version = ">= 0.12.9"
}

# ---------------------------------------------------------------------------------------------------------------------
# SET TERRAFORM AND PROVIDER REQUIREMENTS FOR RUNNING THIS MODULE
# ---------------------------------------------------------------------------------------------------------------------

provider "github" {
# We want to be compatible with 2.x series of github provider
version = ">= 2.6.1, < 3.0.0"

# Read GitHub credentials from environment
# GITHUB_TOKEN
# GITHUB_ORGANIZATION
version = "~> 2.6"
}

provider "tls" {
Expand Down Expand Up @@ -51,6 +37,10 @@ resource "tls_private_key" "deploy" {
module "repository" {
source = "../.."

module_depends_on = [
github_team.team
]

name = var.name
description = var.description
homepage_url = var.url
Expand Down
6 changes: 1 addition & 5 deletions examples/public-repository-with-collaborators/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
# SET TERRAFORM AND PROVIDER REQUIREMENTS FOR RUNNING THIS MODULE
# ---------------------------------------------------------------------------------------------------------------------

terraform {
required_version = "~> 0.12.9"
}

provider "github" {
version = ">= 2.6.1, < 3.0.0"
version = "~> 2.6"
}

module "repository" {
Expand Down
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ resource "github_team_repository" "team_repository_by_slug" {
repository = github_repository.repository.name
team_id = data.github_team.teams[each.key].id
permission = each.value.permission

depends_on = [var.module_depends_on]
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,9 @@ variable "projects" {

default = []
}

variable "module_depends_on" {
type = any
description = "Define resources this module indirectly depends_on."
default = []
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ terraform {
required_version = ">= 0.12.9"

required_providers {
github = ">= 2.6.1, < 3.0.0"
github = "~> 2.6"
}
}