Skip to content

Commit

Permalink
Update all dependencies (#5)
Browse files Browse the repository at this point in the history
* Update all dependencies

* remove deprecated set env

* fix terraform chdir

* Fix tf init

* Fix verions

* Fix cache

* Try fixing pre commit
  • Loading branch information
gordonbondon authored Sep 8, 2024
1 parent 36e4179 commit 02c9cc4
Show file tree
Hide file tree
Showing 14 changed files with 1,141 additions and 667 deletions.
55 changes: 17 additions & 38 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,50 @@ jobs:
lint:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- uses: actions/setup-python@v1
- name: Set PY
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
- uses: actions/cache@v1
- uses: actions/setup-python@v5
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pre-commit-
- uses: actions/cache@v1
python-version: 3.12
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.pre-commit-config.yaml') }}
key: ${{ runner.os }}-pip-${{ hashFiles('.github/workflows/pull_request.yml') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-go@v1
with:
go-version: 1.14
- name: Set GOPATH
run: |
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"
- uses: actions/cache@v1
- uses: actions/setup-go@v5
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
go-version: 1.23
cache-dependency-path: "**/go.sum"
- name: Install tools
working-directory: test
run: |
go install github.com/segmentio/terraform-docs
go install github.com/terraform-docs/terraform-docs
go install github.com/terraform-linters/tflint
- uses: autero1/action-terraform@v0.1.0
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 0.12.21
terraform_version: 1.9

- name: Run terraform init
run: |
configs=$(find . -not -path '*/.terraform/*' -type f -name "*.tf" | xargs -I {} dirname {} | uniq)
for config in $configs; do
terraform init -backend=false $config
terraform -chdir=$config init -backend=false
done
- uses: pre-commit/action@v1.0.1
- uses: pre-commit/action@v3.0.1

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- uses: actions/setup-go@v1
- uses: actions/setup-go@v5
with:
go-version: 1.14
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
go-version: 1.23
cache-dependency-path: "**/go.sum"

- name: Run terratest
working-directory: test
Expand All @@ -83,4 +63,3 @@ jobs:
needs:
- lint
- test

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.terraform
.terraform-version
.terraform.lock.hcl
*.tfstate
*.tfstate.backup
.kitchen
Expand Down
12 changes: 10 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.27.0
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.94.1
hooks:
- id: terraform_fmt
- id: terraform_docs
- id: terraform_validate
exclude: "^test/fixtures/misconfigured"
- id: terraform_tflint
args:
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
exclude: |
(?x)^(
^examples/.*|
^test/fixtures/.*
)$
3 changes: 3 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rule "terraform_unused_declarations" {
enabled = false
}
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module "check" {
source = "gordonbondon/verify/common"
version = "~> 1.0"
match = contains(list("a", "b", "c"), "a")
match = contains(tolist(["a", "b", "c"]), "a")
error = "Value must be one of a,b,c"
}
```
Expand All @@ -24,29 +24,38 @@ module "check" {

* `bash` shell interpreter

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| external | >= 1.1.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 1.1.0 |

## Providers

| Name | Version |
|------|---------|
| external | >= 1.1.0 |
| <a name="provider_external"></a> [external](#provider\_external) | 2.3.3 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [external_external.validate](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| error | error message to display | `string` | n/a | yes |
| match | pass in expression that will evaluate to `true` or `false` | `any` | n/a | yes |
| <a name="input_error"></a> [error](#input\_error) | error message to display | `string` | n/a | yes |
| <a name="input_match"></a> [match](#input\_match) | pass in expression that will evaluate to `true` or `false` | `bool` | n/a | yes |

## Outputs

No output.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
No outputs.
<!-- END_TF_DOCS -->
6 changes: 3 additions & 3 deletions examples/subnets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ data "aws_route" "private_subnet" {

locals {
# get subnet without NAT gateway
temp_rt_no_nat = matchkeys(data.aws_route.private_subnet.*.route_table_id, data.aws_route.private_subnet.*.nat_gateway_id, list(""))
temp_rt_no_nat = matchkeys(data.aws_route.private_subnet[*].route_table_id, data.aws_route.private_subnet[*].nat_gateway_id, tolist([""]))
temp_sub_no_nat = [
for rt_id in local.temp_rt_no_nat : element(var.private_subnet_ids, index(data.aws_route_table.private_subnet.*.id, rt_id))
for rt_id in local.temp_rt_no_nat : element(var.private_subnet_ids, index(data.aws_route_table.private_subnet[*].id, rt_id))
]
}

module "verify_subnet" {
source = "../"

match = length(compact(data.aws_route.private_subnet.*.nat_gateway_id)) == length(var.private_subnet_ids)
match = length(compact(data.aws_route.private_subnet[*].nat_gateway_id)) == length(var.private_subnet_ids)
error = "All private subnets must have a route to NAT gateway. [${join(",", local.temp_sub_no_nat)}] don't have it."
}
2 changes: 1 addition & 1 deletion test/fixtures/invalid/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "verify_list" {
source = "../../../"

match = contains(list("a", "b", "c"), "e")
match = contains(tolist(["a", "b", "c"]), "e")
error = "Value must be in a, b, c"
}
2 changes: 1 addition & 1 deletion test/fixtures/valid/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "verify_list" {
source = "../../../"

match = contains(list("a", "b", "c"), "a")
match = contains(tolist(["a", "b", "c"]), "a")
error = "Value must be in a,b,c"
}
132 changes: 128 additions & 4 deletions test/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,133 @@
module github.com/gordonbondon/terraform-common-verify/test

go 1.14
go 1.23.0

toolchain go1.23.1

require (
github.com/gruntwork-io/terratest v0.47.1
github.com/terraform-docs/terraform-docs v0.18.0
github.com/terraform-linters/tflint v0.53.0
)

require (
github.com/gruntwork-io/terratest v0.27.0
github.com/segmentio/terraform-docs v0.9.1
github.com/terraform-linters/tflint v0.15.5
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/aws/aws-sdk-go v1.44.122 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bmatcuk/doublestar v1.1.5 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github/v53 v53.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.6 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-json v0.13.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jessevdk/go-flags v1.6.1 // indirect
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v1.0.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/owenrumney/go-sarif v1.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/sourcegraph/go-lsp v0.0.0-20200429204803-219e11d77f5d // indirect
github.com/sourcegraph/jsonrpc2 v0.2.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/terraform-docs/terraform-config-inspect v0.0.0-20210728164355-9c1f178932fa // indirect
github.com/terraform-linters/tflint-plugin-sdk v0.21.0 // indirect
github.com/terraform-linters/tflint-ruleset-terraform v0.9.1 // indirect
github.com/tmccombs/hcl2json v0.3.3 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
github.com/zclconf/go-cty-yaml v1.0.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
mvdan.cc/xurls/v2 v2.5.0 // indirect
)
Loading

0 comments on commit 02c9cc4

Please sign in to comment.