Skip to content

Commit ddda658

Browse files
Enhanced tests variables and examples (#6)
* set has_ feature toogles default values to false * set variables default value to null * output complete object * remove unnecessary Vars declaration from test * fix typos
1 parent 64e2296 commit ddda658

File tree

8 files changed

+25
-21
lines changed

8 files changed

+25
-21
lines changed

README.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ image:https://img.shields.io/badge/tf-%3E%3D0.12.9-blue.svg[Terraform Version]
2020

2121
[.lead]
2222
A Terraform module that acts as a wrapper around the Terraform https://www.terraform.io/docs/providers/github/index.html[GitHub provider]
23-
and offers a more convenient and tested way to provision and manage GitHub Repositories within your GitHub organization. following best practices.
23+
and offers a more convenient and tested way to provision and manage GitHub Repositories within your GitHub organization following best practices.
2424

2525
[NOTE]
2626
====
27-
This resource cannot currently be used to manage personal repositories, outside of organizations due to limitations of the Terraform https://www.terraform.io/docs/providers/github/index.html[GitHub provider].
27+
This module cannot currently be used to manage personal repositories, outside of organizations due to limitations of the Terraform https://www.terraform.io/docs/providers/github/index.html[GitHub provider].
2828
====
2929

3030
[TIP]
@@ -33,7 +33,7 @@ This Module uses `For, For-Each and Dynamic Nested Blocks` that were introduced
3333
A common problem in Terraform configurations for versions 0.11 and earlier is dealing with situations where the number
3434
of values or resources is decided by a dynamic expression rather than a fixed count.
3535
36-
Using `For, For-Each and Dynamic Nested Blocks` you can now dynamically add and remove items from and to Lists without
36+
You can now dynamically add and remove items from and to Lists without
3737
the necessity to render the whole list of resources again. Terraform will only add and remove the items you want it to.
3838
====
3939

examples/private-repository-with-team/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ variable "github_token" {
77
variable "github_organization" {
88
type = string
99
description = "Github organization used to deploy this module into. Typically, we set this using variables on the command line to set the value inside our CI environment. https://www.terraform.io/docs/configuration/variables.html#variables-on-the-command-line"
10-
default = ""
10+
default = null
1111
}

examples/public-repository-complete-example/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ variable "github_token" {
77
variable "github_organization" {
88
type = string
99
description = "Github organization used to deploy this module into. Typically, we set this using variables on the command line to set the value inside our CI environment. https://www.terraform.io/docs/configuration/variables.html#variables-on-the-command-line"
10-
default = ""
10+
default = null
1111
}

examples/public-repository-with-collaborators/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ variable "github_token" {
77
variable "github_organization" {
88
type = string
99
description = "Github organization used to deploy this module into. Typically, we set this using variables on the command line to set the value inside our CI environment. https://www.terraform.io/docs/configuration/variables.html#variables-on-the-command-line"
10-
default = ""
10+
default = null
1111
}

examples/public-repository/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ variable "github_token" {
77
variable "github_organization" {
88
type = string
99
description = "Github organization used to deploy this module into. Typically, we set this using variables on the command line to set the value inside our CI environment. https://www.terraform.io/docs/configuration/variables.html#variables-on-the-command-line"
10-
default = ""
10+
default = null
1111
}

outputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ output "git_clone_url" {
1414
value = github_repository.repository.git_clone_url
1515
}
1616

17-
output "collaborator_invitation_id" {
18-
value = { for k, v in github_repository_collaborator.collaborator : k => v.invitation_id }
17+
output "collaborators" {
18+
value = github_repository_collaborator.collaborator
1919
}
2020

21-
output "project_url" {
22-
value = { for k, v in github_repository_project.repository_project : k => v.url }
21+
output "projects" {
22+
value = github_repository_project.repository_project
2323
}

test/github_repository_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ func init() {
1212
githubOrganization = os.Getenv("GITHUB_ORGANIZATION")
1313
githubToken = os.Getenv("GITHUB_TOKEN")
1414

15+
if githubOrganization == "" {
16+
panic("Please set a github organization using the GITHUB_ORGANIZATION environment variable.")
17+
}
18+
1519
if githubToken == "" {
1620
panic("Please set a github token using the GITHUB_TOKEN environment variable.")
1721
}

variables.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ variable "homepage_url" {
1717

1818
variable "private" {
1919
type = bool
20-
description = "Set to true to create a private repository."
21-
default = false
20+
description = "Set to false to create a public repository."
21+
default = true
2222
}
2323

2424
variable "has_issues" {
2525
type = bool
2626
description = "Set to true to enable the GitHub Issues features on the repository."
27-
default = true
27+
default = false
2828
}
2929

3030
variable "has_projects" {
@@ -41,20 +41,20 @@ variable "has_wiki" {
4141

4242
variable "allow_merge_commit" {
4343
type = bool
44-
description = "Set to false to disable merge commits on the repository."
45-
default = true
44+
description = "Set to true to enable merge commits on the repository."
45+
default = false
4646
}
4747

4848
variable "allow_squash_merge" {
4949
type = bool
50-
description = "Set to false to disable squash merges on the repository."
51-
default = true
50+
description = "Set to true to enable squash merges on the repository."
51+
default = false
5252
}
5353

5454
variable "allow_rebase_merge" {
5555
type = bool
56-
description = "Set to false to disable rebase merges on the repository."
57-
default = true
56+
description = "Set to true to enable rebase merges on the repository."
57+
default = false
5858
}
5959

6060
variable "has_downloads" {
@@ -66,7 +66,7 @@ variable "has_downloads" {
6666
variable "auto_init" {
6767
type = bool
6868
description = "Wether or not to produce an initial commit in the repository."
69-
default = true
69+
default = false
7070
}
7171

7272
variable "gitignore_template" {

0 commit comments

Comments
 (0)