1+ # -----------------------------------------------------------------------------
2+ # TERRAFORM
3+ # We need at least version 0.12.9 for full for_each functionality
4+ # -----------------------------------------------------------------------------
15terraform {
26 required_version = " ~> 0.12.9"
37}
48
9+ # -----------------------------------------------------------------------------
10+ # PROVIDERS
11+ # We are using specific version of different providers for consistant results
12+ # -----------------------------------------------------------------------------
513provider "github" {
14+ # we want to be compatible with 2.x series of github provider
615 version = " ~> 2.2"
16+ # credentials are read from the environment
17+ # GITHUB_TOKEN
18+ # GITHUB_ORGANIZATION
19+ }
20+
21+ provider "random" {
22+ version = " = 2.2.1"
23+ }
24+
25+ provider "tls" {
26+ version = " = 2.1.1"
27+ }
28+
29+ # -----------------------------------------------------------------------------
30+ # DEPENDENCIES from other providers
31+ # We are creating some resources for easier testing
32+ # -----------------------------------------------------------------------------
33+ resource "tls_private_key" "deploy" {
34+ count = 2
35+
36+ algorithm = " RSA"
37+ rsa_bits = 4096
738}
839
940resource "random_pet" "suffix" {
1041 length = 1
1142}
1243
44+ # -----------------------------------------------------------------------------
45+ # TEST A
46+ # We are creating a repository, adding teams and setting up branch protection,
47+ # deploy keys, issue labels and projects
48+ # -----------------------------------------------------------------------------
1349module "repository" {
1450 source = " ../.."
1551
16- name = " public-repository-complete-example-1 -${ random_pet . suffix . id } "
52+ name = " test- public-repository-complete-example-A -${ random_pet . suffix . id } "
1753 description = " A public repository created with terraform to test the terraform-github-repository module."
1854 homepage_url = " https://github.com/mineiros-io"
1955 private = false
@@ -76,12 +112,12 @@ module "repository" {
76112 deploy_keys = [
77113 {
78114 title = " CI User Deploy Key"
79- key = " ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjv+wDq3BV0CTTIJYCnUv530ximNPwfrILIXRhhTZNPrDTpxYCO2ACexeX4wN1vfQqsSXwKutdBJoL42kXYHGRpEQ/1iiojJYL3wO7ktdeQuWDEhTyMzOp0FPrEWydzhCXKqcsA+RVPBAwXlsmaw7SkvjVgR9JCNC3OuIoPndMDSeT64/LHMX8UDlS+PikVRZ5rXhOI50Mqijd+xNf55hxURG3Zp1/iIjWCBHZQLOaazd09MD+HB9Hm/df8l6Mo4ahZuJFYfESIt8lR0FfKkfz4FDPil4JcK1BUs2013c4PYyt8JQR08dUIOGBQNe5mhLPJHD0+ylbQJown5Ahs+Nq5aX+1ZrpXlSO5KSsOKlq/Sj2uYyODWhhKuXlCaEU1eQcREhjP0KEx5AVcFCH3rxSC1gTp8w5fEuOeM3As0BPeo/LqLrtQcXnOZpYn/LGlcZE420YP8nfbMZ6I71KSn0+TjnUWQV93r+UMYmfjHwlq14pgPfWmi+nT/4g1n8WAR7VAKv/7fdY/e2gv5w22El1bXSvP+4fH86s+g/gGfxnjVhRB/CgxfrftyzBZOEXGQEGbiY2rJcLbdi2WY6i9rBQkEWCX8ExOK4HYLZ2qbw6jStl+yHDLgUbhwoe7ggzs5mReaMVcU0MQ6PRDJJ+AyI3bledoYFF+h8M8p2afcb3aw== "
115+ key = tls_private_key.deploy[ 0 ].public_key_openssh
80116 read_only = true
81117 },
82118 {
83119 title = " Test Key"
84- key = " ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC7IF88OLL8j1bTvRCernM/J45aoQvOaHNTDkBnMpxWUsf+F3ZBy/ls8yOgeF+OAFCT3tPrh2drGa3cK460/zL2SxAn5mT1bcDJOk7axMcamZ0EpKWAaSbRKxCLkUsTbHiW0nHG+jT7PQCtWwx6CQNh5ztx+Ge5QwDgS7HpyMxIS5Ju4dt5Eh2+MaPMjKWd8P5FKqNCvO4VYy+/3RijeQO+6lM9rih3EECkLug44ZKtbSmQhjHS5/iY7TkfpFpOgMVprgTq5tEK13wrhgjDO5gZ+MopTv5jmuatBLUlpjVI64EHm+zPyxn5E/vehopX8uF1yM1dTt4t6t+p0SRmaCSIX6QOJt9LUmIjrHvseC/TCU8Bfv//QM3GhuaSd1YtbTxbni7R4YX8EKLuBK3bidAj1c9130aML89ckztI9RAiRj+oYyqZqoj1bNG0x1D7XFjyaLf+V+yVrACx/h3PvpG2/dNQ06PRdqAq33dQ7gfsI0qw5QnOCEZimbNigOUuqxf33k2hNkjZCyTXRHhslaY4LoOCIJZrC9dr+a4ENgWw0gVOsuP+Lr6I5UBR4B/H9PtvqAcRjpUOAoJYJiCPgWlglIyuV80u9Uwk11X09E09zEiW+CJWi4RHDWhRNcWO0z5o4nPbEExnXqpiVGPn+WOCsagpap0WXUErrCGhzwuHkQ== "
120+ key = tls_private_key.deploy[ 1 ].public_key_openssh
85121 read_only = false
86122 }
87123 ]
@@ -98,6 +134,10 @@ module "repository" {
98134 ]
99135}
100136
137+ # -----------------------------------------------------------------------------
138+ # TEST B
139+ # We are creating a repository using some defaults defined in locals
140+ # -----------------------------------------------------------------------------
101141locals {
102142 defaults = {
103143 homepage_url = " https://github.com/mineiros-io"
@@ -112,32 +152,27 @@ locals {
112152module "repository-with-defaults" {
113153 source = " ../.."
114154
115- name = " public-repository-complete-example-2 -${ random_pet . suffix . id } "
155+ name = " test- public-repository-complete-example-B -${ random_pet . suffix . id } "
116156 description = " A public repository created with terraform to test the terraform-github-repository module."
117157 defaults = local. defaults
118158}
119159
160+ # -----------------------------------------------------------------------------
161+ # GITHUB DEPENDENCIES: TEAM
162+ # We are creating a github team to be added to the repository
163+ # -----------------------------------------------------------------------------
120164resource "github_team" "team" {
121- name = " private- repository-with-teams-test-team -${ random_pet . suffix . id } "
122- description = " This team is created with terraform to test the terraformn-github-repository module."
165+ name = " test-public- repository-complete-example -${ random_pet . suffix . id } "
166+ description = " A secret team created with terraform to test the terraformn-github-repository module."
123167 privacy = " secret"
124168}
125169
126170# ---------------------------------------------------------------------------------------------------------------------
127171# TEAM MEMBERSHIP
128- # We are adding two members to this team. terraform-test-user-1 and terraform-test-user-2 which are both existing users
129- # and already members of the GitHub Organization terraform-test that is an Organization managed by Mineiros.io to run
130- # integration tests with Terragrunt.
172+ # We are adding one members to this team for testing branch restrictions
173+ # terraform-test-user is permanent normal member of the test organization
131174# ---------------------------------------------------------------------------------------------------------------------
132175
133- resource "github_team_membership" "team_membership" {
134- count = 2
135-
136- team_id = github_team. team . id
137- username = " terraform-test-user-${ count . index + 1 } "
138- role = " member"
139- }
140-
141176resource "github_team_membership" "team_membership_permanent" {
142177 team_id = github_team. team . id
143178 username = " terraform-test-user"
0 commit comments