Skip to content

Commit

Permalink
Enhanced tests variables and examples (#6)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
soerenmartius authored Jan 6, 2020
1 parent 64e2296 commit ddda658
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ image:https://img.shields.io/badge/tf-%3E%3D0.12.9-blue.svg[Terraform Version]

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

[NOTE]
====
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].
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].
====

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

Expand Down
2 changes: 1 addition & 1 deletion examples/private-repository-with-team/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ variable "github_token" {
variable "github_organization" {
type = string
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"
default = ""
default = null
}
2 changes: 1 addition & 1 deletion examples/public-repository-complete-example/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ variable "github_token" {
variable "github_organization" {
type = string
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"
default = ""
default = null
}
2 changes: 1 addition & 1 deletion examples/public-repository-with-collaborators/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ variable "github_token" {
variable "github_organization" {
type = string
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"
default = ""
default = null
}
2 changes: 1 addition & 1 deletion examples/public-repository/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ variable "github_token" {
variable "github_organization" {
type = string
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"
default = ""
default = null
}
8 changes: 4 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ output "git_clone_url" {
value = github_repository.repository.git_clone_url
}

output "collaborator_invitation_id" {
value = { for k, v in github_repository_collaborator.collaborator : k => v.invitation_id }
output "collaborators" {
value = github_repository_collaborator.collaborator
}

output "project_url" {
value = { for k, v in github_repository_project.repository_project : k => v.url }
output "projects" {
value = github_repository_project.repository_project
}
4 changes: 4 additions & 0 deletions test/github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func init() {
githubOrganization = os.Getenv("GITHUB_ORGANIZATION")
githubToken = os.Getenv("GITHUB_TOKEN")

if githubOrganization == "" {
panic("Please set a github organization using the GITHUB_ORGANIZATION environment variable.")
}

if githubToken == "" {
panic("Please set a github token using the GITHUB_TOKEN environment variable.")
}
Expand Down
20 changes: 10 additions & 10 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ variable "homepage_url" {

variable "private" {
type = bool
description = "Set to true to create a private repository."
default = false
description = "Set to false to create a public repository."
default = true
}

variable "has_issues" {
type = bool
description = "Set to true to enable the GitHub Issues features on the repository."
default = true
default = false
}

variable "has_projects" {
Expand All @@ -41,20 +41,20 @@ variable "has_wiki" {

variable "allow_merge_commit" {
type = bool
description = "Set to false to disable merge commits on the repository."
default = true
description = "Set to true to enable merge commits on the repository."
default = false
}

variable "allow_squash_merge" {
type = bool
description = "Set to false to disable squash merges on the repository."
default = true
description = "Set to true to enable squash merges on the repository."
default = false
}

variable "allow_rebase_merge" {
type = bool
description = "Set to false to disable rebase merges on the repository."
default = true
description = "Set to true to enable rebase merges on the repository."
default = false
}

variable "has_downloads" {
Expand All @@ -66,7 +66,7 @@ variable "has_downloads" {
variable "auto_init" {
type = bool
description = "Wether or not to produce an initial commit in the repository."
default = true
default = false
}

variable "gitignore_template" {
Expand Down

0 comments on commit ddda658

Please sign in to comment.