Skip to content

Commit

Permalink
Merge pull request #26 from mineiros-io/soerenmartius/update-module
Browse files Browse the repository at this point in the history
Upgrade module from template
  • Loading branch information
soerenmartius authored Nov 25, 2022
2 parents 6e8aecd + b216be2 commit 11f699e
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 124 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ jobs:
go-version: 1.17.6

- name: Set up Terramate
# for security reasons we pin commit ids and not tags.
# mineiros-io/terramate@v0.1.1 -> bea6836fa912c982f39a2965a327476b15d06b45
run: go install github.com/mineiros-io/terramate/cmd/terramate@bea6836fa912c982f39a2965a327476b15d06b45
env:
GOPROXY: direct
uses: giantswarm/install-binary-action@e97402b0aa95939ddba5b36aa77f8abc58a37fd5
with:
binary: terramate
version: 0.1.41
# https://github.com/mineiros-io/terramate/releases/download/v${version}/terramate_${version}_${os}_${arch}.tar.gz
download_url: "https://github.com/mineiros-io/${binary}/releases/download/v${version}/terramate_${version}_linux_x86_64.tar.gz"
tarball_binary_path: "${binary}"

- name: Clean Up Terramate Install Artifacts
run: rm -rf terramate

- name: Set up Terradoc
# for security reasons we pin commit ids and not tags.
Expand All @@ -58,15 +63,15 @@ jobs:
# hashicorp/setup-terraform@v2.0.0 -> 17d4c9b8043b238f6f35641cdd8433da1e6f3867
uses: hashicorp/setup-terraform@17d4c9b8043b238f6f35641cdd8433da1e6f3867
with:
terraform_version: 1.2.1
terraform_version: 1.3.0
terraform_wrapper: false

- name: Setup TFLint
# for security reasons we pin commit ids and not tags.
# terraform-linters/setup-tflint@v2.0.0 -> 9e653e0f7de0839150e03280e0981e0c25eaf10a
uses: terraform-linters/setup-tflint@9e653e0f7de0839150e03280e0981e0c25eaf10a
with:
tflint_version: v0.29.0
tflint_version: v0.41.0

- name: Setup and run pre-commit
# for security reasons we pin commit ids and not tags.
Expand Down
11 changes: 11 additions & 0 deletions .terramate/manifest.tm.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
vendor {
manifest {
default {
files = [
"/*.tf",
"/README.md",
"/LICENSE",
]
}
}
}
7 changes: 7 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rule "terraform_unused_declarations" {
enabled = false
}

rule "terraform_required_providers" {
enabled = false
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## Added

- Validation added for `database_version` string input variable

## [0.0.5]
Expand Down
16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tests locally.
At this point, make your code changes and constantly test again your new test case to make sure that everything working
properly. Do [commit] early and often and make useful commit messages.

If a backwards incompatible change cannot be avoided, please make sure to call that out when you submit a pull request,
If a backward incompatible change cannot be avoided, please make sure to call that out when you submit a pull request,
explaining why the change is absolutely necessary.

## Create a pull request
Expand All @@ -68,7 +68,7 @@ explaining why the change is absolutely necessary.
Please make sure to include the following:

1. A description of the change, including a link to your GitHub issue.
1. Any notes on backwards incompatibility or downtime.
1. Any notes on backward incompatibility or downtime.

## Merge and release

Expand All @@ -77,14 +77,14 @@ If everything looks good, they will merge the code and release a new version whi

<!-- References -->

[github flow]: https://docs.github.com/en/get-started/quickstart/github-flow
[codeowners]: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
[fork]: https://docs.github.com/en/get-started/quickstart/fork-a-repo
[commit]: https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/making-changes-in-a-branch/committing-and-reviewing-changes-to-your-project
[create a new branch]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository
[create a pull request]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
[pull requests]: https://github.com/mineiros-io/terraform-google-cloud-sql/pulls
[pre-commit-file]: https://github.com/mineiros-io/terraform-google-cloud-sql/blob/main/.pre-commit-config.yaml
[github flow]: https://guides.github.com/introduction/flow/
[codeowners]: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
[fork]: https://help.github.com/en/github/getting-started-with-github/fork-a-repo
[create a new branch]: https://guides.github.com/introduction/flow/
[readme driven development]: https://tom.preston-werner.com/2010/08/23/readme-driven-development.html
[commit]: https://help.github.com/en/desktop/contributing-to-projects/committing-and-reviewing-changes-to-your-project
[create a pull request]: https://help.github.com/articles/creating-a-pull-request/
[semantic versioning (semver)]: https://semver.org/
[test driven development]: https://en.wikipedia.org/wiki/Test-driven_development
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2020-2021] [Mineiros GmbH]
Copyright [2020-2022] [Mineiros GmbH]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
24 changes: 24 additions & 0 deletions terramate.tm.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
stack {
name = "terraform-google-cloud-sql"
description = "github.com/mineiros-io/terraform-google-cloud-sql"
}

generate_hcl "versions.tf" {
condition = terramate.stack.path.absolute == "/"

content {
terraform {
required_version = global.terraform_version_constraint

tm_dynamic required_providers {
for_each = [1]
attributes = {
"${global.provider}" = {
source = "hashicorp/${global.provider}"
version = global.provider_version_constraint
}
}
}
}
}
}
4 changes: 2 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[<img src="https://raw.githubusercontent.com/mineiros-io/brand/3bffd30e8bdbbde32c143e2650b2faa55f1df3ea/mineiros-primary-logo.svg" width="400"/>][homepage]
[<img src="https://raw.githubusercontent.com/mineiros-io/brand/f2042a229e8feb4b188bea0aec4f6f2ad900c82e/mineiros-primary-logo.svg" width="400"/>][homepage]

[![license][badge-license]][apache20]
[![Join Slack][badge-slack]][slack]
Expand Down Expand Up @@ -110,6 +110,6 @@ Alternatively, you can also run the tests without Docker.
[go]: https://golang.org/
[terraform]: https://www.terraform.io/downloads.html
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack
[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f43f5e.svg?logo=slack
[apache20]: https://opensource.org/licenses/Apache-2.0
[slack]: https://mineiros.io/slack
2 changes: 1 addition & 1 deletion test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/mineiros-io/terraform-google-cloud-sql/test
go 1.14

require (
github.com/gruntwork-io/terratest v0.40.13
github.com/gruntwork-io/terratest v0.40.17
github.com/stretchr/testify v1.7.0
)
11 changes: 6 additions & 5 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/gruntwork-io/go-commons v0.8.0/go.mod h1:gtp0yTtIBExIZp7vyIV9I0XQkVwiQZze678hvDXof78=
github.com/gruntwork-io/terratest v0.40.13 h1:RTJnPTO2kalzkjrNb7nKoKGWfWYnHsf5UzPG3USZBWI=
github.com/gruntwork-io/terratest v0.40.13/go.mod h1:xlVN8UHxN93Z5nt61I0gTU/FESm2C78rYS+/3xcDDdI=
github.com/gruntwork-io/terratest v0.40.17 h1:veSr7MUtk5GRDg5/pZ9qLUvrylr7yuRw0fY9UaSHbuI=
github.com/gruntwork-io/terratest v0.40.17/go.mod h1:enUpxNMsQfiJTTJMGqiznxohqJ4cYPU+nzI3bQNw1WM=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand All @@ -449,8 +449,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-getter v1.5.11 h1:wioTuNmaBU3IE9vdFtFMcmZWj0QzLc6DYaP6sNe5onY=
github.com/hashicorp/go-getter v1.5.11/go.mod h1:9i48BP6wpWweI/0/+FBjqLrp9S8XtwUGjiu0QkWHEaY=
github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY=
github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
Expand Down Expand Up @@ -1018,8 +1018,9 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644 h1:CA1DEQ4NdKphKeL70tvsWNdT5oFh1lOjihRcEDROi0I=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e h1:w36l2Uw3dRan1K3TyXriXvY+6T56GNmlKGcqiQUJDfM=
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
45 changes: 0 additions & 45 deletions test/terramate_aws.tm.hcl

This file was deleted.

48 changes: 28 additions & 20 deletions test/terramate_google.tm.hcl
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
globals {
minimum_provider_version = "4.4"
provider_version_constraint = "~> ${global.minimum_provider_version}"

stack_basename = tm_reverse(tm_split("/", terramate.path))[0]
}

generate_hcl "_generated_google.tf" {
# condition = global.provider == "google"
condition = global.provider == "google" || global.provider == "google-beta"
content {
variable "gcp_project" {
type = string
description = "(Required) The ID of the project in which the resource belongs."
description = "(Optional) The ID of the project in which the resource belongs."
default = null
}

variable "gcp_region" {
Expand All @@ -28,7 +22,7 @@ generate_hcl "_generated_google.tf" {
variable "gcp_billing_account" {
type = string
description = "(Optional) The billing account to use when creating projects."
default = null
default = "test-billing-account"
}

terraform {
Expand All @@ -37,6 +31,10 @@ generate_hcl "_generated_google.tf" {
source = "hashicorp/google"
version = global.provider_version_constraint
}
google-beta = {
source = "hashicorp/google-beta"
version = global.provider_version_constraint
}
random = {
source = "hashicorp/random"
version = "~> 3.1"
Expand All @@ -49,30 +47,40 @@ generate_hcl "_generated_google.tf" {
region = var.gcp_region
}

provider "google-beta" {
project = var.gcp_project
region = var.gcp_region
}

provider "random" {}

resource "random_id" "suffix" {
count = local.test_name != "unit-disabled" ? 1 : 0
byte_length = 16
}

data "google_project" "project" {}
data "google_project" "project" {
count = var.gcp_project != null ? 1 : 0

project_id = var.gcp_project
}

data "google_organization" "org" {
count = local.org_domain != null ? 1 : 0
count = var.gcp_org_domain != null ? 1 : 0

domain = local.org_domain
domain = var.gcp_org_domain
}

# define default locals for all tests
locals {
test_name = global.stack_basename
random_suffix = try(random_id.suffix[0].hex, "disabled")
project_id = var.gcp_project
project_number = data.google_project.project.number
org_domain = var.gcp_org_domain
org_id = try(data.google_organization.org[0].name, null)
billing_account = var.gcp_billing_account
test_name = terramate.stack.path.basename
random_suffix = try(random_id.suffix[0].hex, "disabled")
project_id = try(data.google_project.project[0].project_id, "no-project")
project_number = try(data.google_project.project[0].number, null)
org_domain = try(data.google_organization.org[0].domain, "no-domain.mineiros.io")
org_id = try(data.google_organization.org[0].org_id, null)
billing_account = var.gcp_billing_account
directory_customer_id = try(data.google_organization.org[0].directory_customer_id, "no-directoy-customer")
}
}
}
Loading

0 comments on commit 11f699e

Please sign in to comment.