Skip to content

Commit

Permalink
feat: correct linting errors and add .releaserc.json file to fix re…
Browse files Browse the repository at this point in the history
…lease process (#28)
  • Loading branch information
bryantbiggs authored Dec 7, 2021
1 parent 0478736 commit 0e4e8b5
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.58.0
rev: v1.59.0
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand Down
36 changes: 36 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"branches": [
"main",
"master"
],
"ci": false,
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"successComment":
"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
"labels": false,
"releasedLabels": false
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md"
],
"message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
2 changes: 1 addition & 1 deletion files/terraform-modules/pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.58.0
rev: v1.59.0
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand Down
4 changes: 0 additions & 4 deletions modules/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_branch"></a> [branch](#input\_branch) | Branch name | `string` | `"master"` | no |
| <a name="input_dynamic_files"></a> [dynamic\_files](#input\_dynamic\_files) | Map of dynamic files to manage in repo (generated from templates) | `map(any)` | `{}` | no |
| <a name="input_files_dir"></a> [files\_dir](#input\_files\_dir) | Path to files directory | `string` | n/a | yes |
| <a name="input_labels"></a> [labels](#input\_labels) | Map of Github issue labels (`label => color` or `label => { color, description }`) | `any` | `{}` | no |
| <a name="input_repository"></a> [repository](#input\_repository) | Repository owner/name | `string` | n/a | yes |
| <a name="input_static_files"></a> [static\_files](#input\_static\_files) | Map of static files to manage in repo | `map(any)` | `{}` | no |

## Outputs

Expand Down
6 changes: 3 additions & 3 deletions modules/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ terraform {
}
}

locals {
clean_static_files = { for k, v in var.static_files : k => v if v != null }
}
# locals {
# clean_static_files = { for k, v in var.static_files : k => v if v != null }
# }

# resource "githubfile_file" "static" {
# for_each = local.clean_static_files
Expand Down
Empty file added modules/github/outputs.tf
Empty file.
38 changes: 19 additions & 19 deletions modules/github/variables.tf
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
variable "files_dir" {
description = "Path to files directory"
type = string
}
# variable "files_dir" {
# description = "Path to files directory"
# type = string
# }

variable "repository" {
description = "Repository owner/name"
type = string
}

variable "branch" {
description = "Branch name"
type = string
default = "master"
}
# variable "branch" {
# description = "Branch name"
# type = string
# default = "master"
# }

variable "static_files" {
description = "Map of static files to manage in repo"
type = map(any)
default = {}
}
# variable "static_files" {
# description = "Map of static files to manage in repo"
# type = map(any)
# default = {}
# }

variable "dynamic_files" {
description = "Map of dynamic files to manage in repo (generated from templates)"
type = map(any)
default = {}
}
# variable "dynamic_files" {
# description = "Map of dynamic files to manage in repo (generated from templates)"
# type = map(any)
# default = {}
# }

variable "labels" {
description = "Map of Github issue labels (`label => color` or `label => { color, description }`)"
Expand Down
20 changes: 10 additions & 10 deletions modules/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ $ terraform apply

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.23 |
| <a name="requirement_github"></a> [github](#requirement\_github) | ~> 2.4 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.0 |
| <a name="requirement_github"></a> [github](#requirement\_github) | ~> 4.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_github"></a> [github](#provider\_github) | ~> 2.4 |
| <a name="provider_github"></a> [github](#provider\_github) | ~> 4.0 |

## Modules

Expand All @@ -34,13 +34,13 @@ No modules.

| Name | Type |
|------|------|
| [github_branch_protection.this](https://registry.terraform.io/providers/hashicorp/github/latest/docs/resources/branch_protection) | resource |
| [github_membership.admins](https://registry.terraform.io/providers/hashicorp/github/latest/docs/resources/membership) | resource |
| [github_membership.members](https://registry.terraform.io/providers/hashicorp/github/latest/docs/resources/membership) | resource |
| [github_repository.this](https://registry.terraform.io/providers/hashicorp/github/latest/docs/resources/repository) | resource |
| [github_team.this](https://registry.terraform.io/providers/hashicorp/github/latest/docs/resources/team) | resource |
| [github_team_membership.this](https://registry.terraform.io/providers/hashicorp/github/latest/docs/resources/team_membership) | resource |
| [github_team_repository.this](https://registry.terraform.io/providers/hashicorp/github/latest/docs/resources/team_repository) | resource |
| [github_branch_protection.this](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection) | resource |
| [github_membership.admins](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/membership) | resource |
| [github_membership.members](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/membership) | resource |
| [github_repository.this](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository) | resource |
| [github_team.this](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/team) | resource |
| [github_team_membership.this](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/team_membership) | resource |
| [github_team_repository.this](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/team_repository) | resource |

## Inputs

Expand Down
7 changes: 3 additions & 4 deletions modules/main/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
terraform {
required_version = ">= 0.12.23"
required_version = "~> 1.0"

required_providers {
# There is a bug in 2.4.1 with github_branch_protection import resource - https://github.com/terraform-providers/terraform-provider-github/issues/386
github = {
source = "hashicorp/github"
version = "~> 2.4"
source = "integrations/github"
version = "~> 4.0"
}
}
}
Empty file added modules/main/outputs.tf
Empty file.
27 changes: 9 additions & 18 deletions modules/main/repositories.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
locals {
/* Useful helpers */
list_cmd = [for k in keys(var.repositories) : "mkdir \"${k}\""]
full_cmd = join("\n", local.list_cmd)
full_repos = join("\n", keys(var.repositories))
# Useful helpers
# list_cmd = [for k in keys(var.repositories) : "mkdir \"${k}\""]
# full_cmd = join("\n", local.list_cmd)
# full_repos = join("\n", keys(var.repositories))
}

###############
Expand All @@ -14,7 +14,7 @@ resource "github_repository" "this" {
name = each.key
description = lookup(each.value, "description", null)
homepage_url = lookup(each.value, "homepage_url", null)
private = lookup(each.value, "private", false)
visibility = lookup(each.value, "visibility", "public")
has_issues = lookup(each.value, "has_issues", true)
has_projects = lookup(each.value, "has_projects", false)
has_wiki = lookup(each.value, "has_wiki", false)
Expand All @@ -35,8 +35,8 @@ resource "github_repository" "this" {
resource "github_branch_protection" "this" {
for_each = var.branch_protections

repository = github_repository.this[split("/", each.key)[0]].name
branch = split("/", each.key)[1]
repository_id = github_repository.this[each.key].node_id
pattern = "master"

enforce_admins = lookup(each.value, "enforce_admins", false)
require_signed_commits = lookup(each.value, "require_signed_commits", false)
Expand All @@ -55,19 +55,10 @@ resource "github_branch_protection" "this" {

content {
dismiss_stale_reviews = lookup(required_pull_request_reviews.value, "dismiss_stale_reviews", false)
dismissal_users = lookup(required_pull_request_reviews.value, "dismissal_users", null)
dismissal_teams = lookup(required_pull_request_reviews.value, "dismissal_teams", null)
restrict_dismissals = lookup(required_pull_request_reviews.value, "restrict_dismissals", null)
dismissal_restrictions = lookup(required_pull_request_reviews.value, "dismissal_restrictions", null)
require_code_owner_reviews = lookup(required_pull_request_reviews.value, "require_code_owner_reviews", false)
required_approving_review_count = lookup(required_pull_request_reviews.value, "required_approving_review_count", null)
}
}

dynamic "restrictions" {
for_each = length(keys(lookup(each.value, "restrictions", {}))) == 0 ? [] : [lookup(each.value, "restrictions", {})]

content {
users = lookup(restrictions.value, "users", null)
teams = lookup(restrictions.value, "teams", null)
}
}
}
15 changes: 7 additions & 8 deletions modules/main/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ variable "teams" {
type = any
default = {}

// validation {
// condition = ! contains([for v in var.teams : contains(["secret", "closed"], lookup(v, "privacy", "secret"))], false)
// error_message = "The teams privacy should be only 'secret' or 'closed'. Default is 'secret'."
// }

# validation {
# condition = !contains([for v in var.teams : contains(["secret", "closed"], lookup(v, "privacy", "secret"))], false)
# error_message = "The teams privacy should be only 'secret' or 'closed'. Default is 'secret'."
# }
}
variable "team_memberships" {
description = "Map of team memberships to manage"
Expand All @@ -23,16 +22,16 @@ variable "team_memberships" {

variable "team_repositories" {
description = "Map of team repositories to manage"
// key = team-name/repo-name
// value = permission (described here - https://help.github.com/articles/repository-permission-levels-for-an-organization )
# key = team-name/repo-name
# value = permission (described here - https://help.github.com/articles/repository-permission-levels-for-an-organization )
type = map(string)
default = {}
}

variable "branch_protections" {
description = "Map of team memberships to manage"

// key = team-name/repo-name
# key = team-name/repo-name
type = any
default = {}
}
Expand Down

0 comments on commit 0e4e8b5

Please sign in to comment.