-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,407 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,58 @@ | ||
# org-organization | ||
|
||
This module creates following resources. | ||
|
||
- `github_membership` (optional) | ||
- `github_organization_block` (optional) | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1 | | ||
| <a name="requirement_github"></a> [github](#requirement\_github) | = 4.13.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_github"></a> [github](#provider\_github) | 4.13.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [github_membership.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/membership) | resource | | ||
| [github_organization_block.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/organization_block) | resource | | ||
| [github_organization.after](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/data-sources/organization) | data source | | ||
| [github_organization.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/data-sources/organization) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the organization. | `string` | n/a | yes | | ||
| <a name="input_blocked_users"></a> [blocked\_users](#input\_blocked\_users) | (Optional) A list of usernames to block from organization. | `set(string)` | `[]` | no | | ||
| <a name="input_members"></a> [members](#input\_members) | (Optional) A list of usernames to add users as `member` role. When applied, an invitation will be sent to the user to become a member of the organization. | `set(string)` | `[]` | no | | ||
| <a name="input_owners"></a> [owners](#input\_owners) | (Optional) A list of usernames to add users as `admin` role. When applied, an invitation will be sent to the user to become an owner of the organization. | `set(string)` | `[]` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_all_members"></a> [all\_members](#output\_all\_members) | A list of all members of the organization. | | ||
| <a name="output_blocked_users"></a> [blocked\_users](#output\_blocked\_users) | A list of blocked usernames from organization. | | ||
| <a name="output_description"></a> [description](#output\_description) | The description of the organization. | | ||
| <a name="output_display_name"></a> [display\_name](#output\_display\_name) | The display name of the organization. | | ||
| <a name="output_id"></a> [id](#output\_id) | The ID of the organization. | | ||
| <a name="output_members"></a> [members](#output\_members) | A list of the members of the organization. | | ||
| <a name="output_name"></a> [name](#output\_name) | The name of the organization. | | ||
| <a name="output_owners"></a> [owners](#output\_owners) | A list of the owners of the organization. | | ||
| <a name="output_plan"></a> [plan](#output\_plan) | The billing plan of the organization. | | ||
| <a name="output_repositories"></a> [repositories](#output\_repositories) | A list of the repositories of the organization. | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
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,53 @@ | ||
data "github_organization" "this" { | ||
name = var.name | ||
} | ||
|
||
data "github_organization" "after" { | ||
name = var.name | ||
|
||
depends_on = [ | ||
github_membership.this | ||
] | ||
} | ||
|
||
locals { | ||
members = [ | ||
for member in var.members : { | ||
username = member | ||
role = "member" | ||
} | ||
] | ||
owners = [ | ||
for owner in var.owners : { | ||
username = owner | ||
role = "admin" | ||
} | ||
] | ||
membership = concat(local.members, local.owners) | ||
} | ||
|
||
|
||
################################################### | ||
# Membership of GitHub Organization | ||
################################################### | ||
|
||
resource "github_membership" "this" { | ||
for_each = { | ||
for member in local.membership : | ||
member.username => member | ||
} | ||
|
||
username = each.key | ||
role = each.value.role | ||
} | ||
|
||
|
||
################################################### | ||
# Blocked Users of GitHub Organization | ||
################################################### | ||
|
||
resource "github_organization_block" "this" { | ||
for_each = toset(var.blocked_users) | ||
|
||
username = each.key | ||
} |
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,49 @@ | ||
output "name" { | ||
description = "The name of the organization." | ||
value = data.github_organization.this.login | ||
} | ||
|
||
output "display_name" { | ||
description = "The display name of the organization." | ||
value = data.github_organization.this.name | ||
} | ||
|
||
output "id" { | ||
description = "The ID of the organization." | ||
value = data.github_organization.this.id | ||
} | ||
|
||
output "description" { | ||
description = "The description of the organization." | ||
value = data.github_organization.this.description | ||
} | ||
|
||
output "plan" { | ||
description = "The billing plan of the organization." | ||
value = data.github_organization.this.plan | ||
} | ||
|
||
output "owners" { | ||
description = "A list of the owners of the organization." | ||
value = var.owners | ||
} | ||
|
||
output "members" { | ||
description = "A list of the members of the organization." | ||
value = var.members | ||
} | ||
|
||
output "all_members" { | ||
description = "A list of all members of the organization." | ||
value = data.github_organization.after.members | ||
} | ||
|
||
output "repositories" { | ||
description = "A list of the repositories of the organization." | ||
value = data.github_organization.this.repositories | ||
} | ||
|
||
output "blocked_users" { | ||
description = "A list of blocked usernames from organization." | ||
value = var.blocked_users | ||
} |
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,22 @@ | ||
variable "name" { | ||
description = "(Required) The name of the organization." | ||
type = string | ||
} | ||
|
||
variable "owners" { | ||
description = "(Optional) A list of usernames to add users as `admin` role. When applied, an invitation will be sent to the user to become an owner of the organization." | ||
type = set(string) | ||
default = [] | ||
} | ||
|
||
variable "members" { | ||
description = "(Optional) A list of usernames to add users as `member` role. When applied, an invitation will be sent to the user to become a member of the organization." | ||
type = set(string) | ||
default = [] | ||
} | ||
|
||
variable "blocked_users" { | ||
description = "(Optional) A list of usernames to block from organization." | ||
type = set(string) | ||
default = [] | ||
} |
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,12 @@ | ||
terraform { | ||
required_version = ">= 1.1" | ||
|
||
required_providers { | ||
github = { | ||
# source = "integrations/github" | ||
# version = ">= 4.19" | ||
source = "hashicorp/github" | ||
version = "= 4.13.0" | ||
} | ||
} | ||
} |
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,61 @@ | ||
# org-team | ||
|
||
This module creates following resources. | ||
|
||
- `github_team` | ||
- `github_team_membership` (optional) | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1 | | ||
| <a name="requirement_github"></a> [github](#requirement\_github) | = 4.13.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_github"></a> [github](#provider\_github) | 4.13.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [github_team.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/team) | resource | | ||
| [github_team_membership.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/team_membership) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the team. | `string` | n/a | yes | | ||
| <a name="input_default_maintainer_enabled"></a> [default\_maintainer\_enabled](#input\_default\_maintainer\_enabled) | (Optional) If true, adds the creating user as a default maintainer to the team. | `bool` | `false` | no | | ||
| <a name="input_description"></a> [description](#input\_description) | (Optional) A description of the team. | `string` | `"Managed by Terraform."` | no | | ||
| <a name="input_is_secret"></a> [is\_secret](#input\_is\_secret) | (Optional) If true, team is only visible to the people on the team and people with owner permissions. | `bool` | `false` | no | | ||
| <a name="input_ldap_group_dn"></a> [ldap\_group\_dn](#input\_ldap\_group\_dn) | (Optional) The LDAP Distinguished Name of the group where membership will be synchronized. Only available in GitHub Enterprise Server. | `string` | `null` | no | | ||
| <a name="input_maintainers"></a> [maintainers](#input\_maintainers) | (Optional) A list of usernames to add users as `maintainer` role. When applied, the user will become a maintainer of the team. | `set(string)` | `[]` | no | | ||
| <a name="input_members"></a> [members](#input\_members) | (Optional) A list of usernames to add users as `member` role. When applied, the user will become a member of the team. | `set(string)` | `[]` | no | | ||
| <a name="input_parent_id"></a> [parent\_id](#input\_parent\_id) | (Optional) The ID of the parent team, if this is a nested team. | `string` | `null` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_default_maintainer_enabled"></a> [default\_maintainer\_enabled](#output\_default\_maintainer\_enabled) | Whether to add the creating user as a default maintainer. | | ||
| <a name="output_description"></a> [description](#output\_description) | The description of the team. | | ||
| <a name="output_id"></a> [id](#output\_id) | The ID of the team. | | ||
| <a name="output_is_secret"></a> [is\_secret](#output\_is\_secret) | Whether to be only visible to the people on the team and people with owner permissions. | | ||
| <a name="output_ldap_group_dn"></a> [ldap\_group\_dn](#output\_ldap\_group\_dn) | The LDAP Distinguished Name of the group where membership will be synchronized. | | ||
| <a name="output_maintainers"></a> [maintainers](#output\_maintainers) | A list of the maintainers of the team. | | ||
| <a name="output_members"></a> [members](#output\_members) | A list of the members of the team. | | ||
| <a name="output_name"></a> [name](#output\_name) | The name of the team. | | ||
| <a name="output_node_id"></a> [node\_id](#output\_node\_id) | The Node ID of the team. | | ||
| <a name="output_parent_id"></a> [parent\_id](#output\_parent\_id) | The ID of the parent team. | | ||
| <a name="output_slug"></a> [slug](#output\_slug) | The slug of the team. | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
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,42 @@ | ||
resource "github_team" "this" { | ||
name = var.name | ||
description = try(var.description, null) | ||
privacy = var.is_secret ? "secret" : "closed" | ||
|
||
parent_team_id = try(var.parent_id, null) | ||
create_default_maintainer = var.default_maintainer_enabled | ||
|
||
ldap_dn = try(var.ldap_group_dn, null) | ||
} | ||
|
||
locals { | ||
members = [ | ||
for member in var.members : { | ||
username = member | ||
role = "member" | ||
} | ||
] | ||
maintainers = [ | ||
for maintainer in var.maintainers : { | ||
username = maintainer | ||
role = "maintainer" | ||
} | ||
] | ||
membership = concat(local.members, local.maintainers) | ||
} | ||
|
||
|
||
################################################### | ||
# Membership of GitHub Organization Team | ||
################################################### | ||
|
||
resource "github_team_membership" "this" { | ||
for_each = { | ||
for member in local.membership : | ||
member.username => member | ||
} | ||
|
||
team_id = github_team.this.id | ||
username = each.key | ||
role = each.value.role | ||
} |
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,54 @@ | ||
output "id" { | ||
description = "The ID of the team." | ||
value = github_team.this.id | ||
} | ||
|
||
output "node_id" { | ||
description = "The Node ID of the team." | ||
value = github_team.this.node_id | ||
} | ||
|
||
output "slug" { | ||
description = "The slug of the team." | ||
value = github_team.this.slug | ||
} | ||
|
||
output "name" { | ||
description = "The name of the team." | ||
value = github_team.this.name | ||
} | ||
|
||
output "description" { | ||
description = "The description of the team." | ||
value = github_team.this.description | ||
} | ||
|
||
output "is_secret" { | ||
description = "Whether to be only visible to the people on the team and people with owner permissions." | ||
value = var.is_secret | ||
} | ||
|
||
output "parent_id" { | ||
description = "The ID of the parent team." | ||
value = github_team.this.parent_team_id | ||
} | ||
|
||
output "ldap_group_dn" { | ||
description = "The LDAP Distinguished Name of the group where membership will be synchronized." | ||
value = var.ldap_group_dn | ||
} | ||
|
||
output "default_maintainer_enabled" { | ||
description = "Whether to add the creating user as a default maintainer." | ||
value = github_team.this.create_default_maintainer | ||
} | ||
|
||
output "maintainers" { | ||
description = "A list of the maintainers of the team." | ||
value = var.maintainers | ||
} | ||
|
||
output "members" { | ||
description = "A list of the members of the team." | ||
value = var.members | ||
} |
Oops, something went wrong.