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
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
repos:
- repo: https://github.com/mineiros-io/pre-commit-hooks
rev: v0.0.5
rev: v0.1.0
hooks:
- id: terraform-fmt
- id: terraform-validate
- id: tflint
- id: gofmt
- id: goimports
- id: golint
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Set default shell to bash
SHELL := /bin/bash

MOUNT_TARGET_DIRECTORY = /app/src
BUILD_TOOLS_DOCKER_REPO = mineiros/build-tools

Expand Down Expand Up @@ -37,7 +40,7 @@ docker/pre-commit-hooks:
@docker run --rm \
-v ${PWD}:${MOUNT_TARGET_DIRECTORY} \
${BUILD_TOOLS_DOCKER_IMAGE} \
sh -c "pre-commit install && pre-commit run --all-files"
sh -c "pre-commit run -a"

## Mounts the working directory inside a new container and runs the Go tests. Requires $GITHUB_TOKEN and $GITHUB_ORGANIZATION to be set
docker/unit-tests:
Expand All @@ -47,6 +50,6 @@ docker/unit-tests:
-e GITHUB_ORGANIZATION \
-v ${PWD}:${MOUNT_TARGET_DIRECTORY} \
${BUILD_TOOLS_DOCKER_IMAGE} \
go test -v -timeout 10m -parallel 128 test/github_repository_test.go
go test -v -timeout 10m -parallel 128 ./test

.PHONY: help docker/pre-commit-hooks docker/run-tests
.PHONY: help docker/pre-commit-hooks docker/unit-tests
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ features like Branch Protection or Collaborator Management.
Gitignore Template,
Template Repository

- **Extended S3 Features**:
- **Extended Repository Features**:
Branch Protection,
Issue Labels,
Handle Github Default Issue Labels,
Expand Down Expand Up @@ -424,7 +424,7 @@ Given a version number `MAJOR.MINOR.PATCH`, we increment the:
2) `MINOR` version when we add functionality in a backwards compatible manner, and
3) `PATCH` version when we make backwards compatible bug fixes.

#### Backwards compatibility in `0.0.z` and `0.y.z` version
### Backwards compatibility in `0.0.z` and `0.y.z` version
- Backwards compatibility in versions `0.0.z` is **not guaranteed** when `z` is increased. (Initial development)
- Backwards compatibility in versions `0.y.z` is **not guaranteed** when `y` is increased. (Pre-release)

Expand Down
61 changes: 36 additions & 25 deletions examples/private-repository-with-team/main.tf
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# CREATE A PRIVATE REPOSITORY WITH AN ATTACHED TEAM
# - create a private repository
# - create a team and invite members
# - add the team to the repository and grant admin permissions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ---------------------------------------------------------------------------------------------------------------------
# SET TERRAFORM AND PROVIDER REQUIREMENTS FOR RUNNING THIS MODULE
# ---------------------------------------------------------------------------------------------------------------------
terraform {
required_version = "~> 0.12.9"
}
required_version = ">= 0.12.9"

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


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

name = "private-repository-with-teams"
description = "A private repository created with terraform to test the terraform-github-repository module."
homepage_url = "https://github.com/mineiros-io"
name = var.name
description = var.description
homepage_url = var.homepage_url
private = true
has_issues = true
has_projects = true
has_wiki = true
allow_merge_commit = true
allow_rebase_merge = true
allow_squash_merge = true
has_downloads = false
auto_init = true
has_issues = var.has_issues
has_projects = var.has_projects
has_wiki = var.has_wiki
allow_merge_commit = var.allow_merge_commit
allow_rebase_merge = var.allow_rebase_merge
allow_squash_merge = var.allow_squash_merge
has_downloads = var.has_downloads
auto_init = var.auto_init
gitignore_template = "Terraform"
license_template = "mit"
archived = false
Expand All @@ -43,37 +54,37 @@ module "repository" {

required_pull_request_reviews = {
dismiss_stale_reviews = true
dismissal_users = ["terraform-test-user-1"]
dismissal_users = var.members
dismissal_teams = [github_team.team.slug]
require_code_owner_reviews = true
required_approving_review_count = 1
}

restrictions = {
users = ["terraform-test-user-1"]
teams = ["team-1"]
users = var.members
teams = [github_team.team.slug]
}
}
]
}

resource "github_team" "team" {
name = "private-repository-with-teams-test-team"
description = "This team is created with terraform to test the terraformn-github-repository module."
name = var.team_name
description = var.team_description
privacy = "secret"
}

# ---------------------------------------------------------------------------------------------------------------------
# TEAM MEMBERSHIP
# We are adding two members to this team. terraform-test-user-1 and terraform-test-user-2 which are both existing users
# and already members of the GitHub Organization terraform-test that is an Organization managed by Mineiros.io to run
# integration tests with Terragrunt.
# We are adding two members to this team. terraform-test-user-1 and terraform-test-user-2 that we define as default
# members in our variables.tf are both existing users and already members of the GitHub Organization terraform-test that
# is an Organization managed by Mineiros.io to run integration tests with Terratest.
# ---------------------------------------------------------------------------------------------------------------------

resource "github_team_membership" "team_membership" {
count = 2
count = length(var.members)

team_id = github_team.team.id
username = "terraform-test-user-${count.index}"
username = var.members[count.index]
role = "member"
}
9 changes: 9 additions & 0 deletions examples/private-repository-with-team/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "repository" {
description = "All outputs of the repository."
value = module.repository
}

output "team" {
description = "All outputs of the team."
value = github_team.team
}
104 changes: 104 additions & 0 deletions examples/private-repository-with-team/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# ---------------------------------------------------------------------------------------------------------------------
# ENVIRONMENT VARIABLES
# Define these secrets as environment variables.
# ---------------------------------------------------------------------------------------------------------------------

# GITHUB_ORGANIZATION
# GITHUB_TOKEN

# ---------------------------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# These variables must be set when using this module.
# ---------------------------------------------------------------------------------------------------------------------

# ---------------------------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# These variables have defaults, but may be overridden.
# ---------------------------------------------------------------------------------------------------------------------

variable "name" {
type = string
description = "The name of the repository."
default = "private-test-repository-with-admin-team"
}

variable "description" {
type = string
description = "A description of the repository."
default = "A private repository created with terraform to test the terraform-github-repository module."
}

variable "homepage_url" {
description = "The website of the repository."
type = string
default = "https://github.com/mineiros-io"
}

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

variable "has_projects" {
description = "Set to true to enable the GitHub Projects features on the repository."
type = bool
default = true
}

variable "has_wiki" {
description = "Set to true to enable the GitHub Wiki features on the repository."
type = bool
default = true
}

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

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

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

variable "has_downloads" {
description = "Set to true to enable the (deprecated) downloads features on the repository."
type = bool
default = false
}

variable "auto_init" {
description = "Wether or not to produce an initial commit in the repository."
type = bool
default = true
}

variable "members" {
description = "A list of members to add to the team."
type = list(string)
default = [
"terraform-test-user-1",
"terraform-test-user-2"
]
}

variable "team_name" {
description = "The name of the created team."
type = string
default = "private-repository-with-teams-test-team"
}

variable "team_description" {
description = "The description of the created team."
type = string
default = "This team is created with terraform to test the terraformn-github-repository module."
}
Loading