Skip to content

Commit

Permalink
Merge pull request #101 from ministryofjustice/tf-validation
Browse files Browse the repository at this point in the history
feat(tf): add validation for modules variables
  • Loading branch information
jackstockley89 authored Feb 2, 2024
2 parents 8c35a8c + 2dc4c13 commit 0386403
Show file tree
Hide file tree
Showing 14 changed files with 1,112 additions and 377 deletions.
41 changes: 31 additions & 10 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,37 @@ on:
types: [opened, edited, reopened, synchronize]

jobs:
go-tests:
name: Run Terratest Unit Tests
ecr-success-validation:
name: Run Terratest Success Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v2
- name: checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
with:
terraform_version: 1.2.5
terraform_wrapper: false
- run: |
terraform init
terraform validate
working-directory: examples/
go-version: 1.21.6
- name: Run Terratest Unit Tests
run: |
go mod download
go test -v -run TestECRValidateSuccess -timeout 30m ./...
working-directory: test

ecr-failure-validation:
name: Run Terratest Failure Unit Tests
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.21.6
- name: Run Terratest Unit Tests
run: |
go mod download
go test -v -run TestECRValidateFailure -timeout 30m ./...
working-directory: test

4 changes: 2 additions & 2 deletions examples/ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/
module "ecr" {
source = "github.com/ministryofjustice/cloud-platform-terraform-ecr-credentials?ref=6.1.0"
source = "github.com/ministryofjustice/cloud-platform-terraform-ecr-credentials?ref=tf-validation"

# Repository configuration
repo_name = var.namespace
Expand All @@ -22,4 +22,4 @@ module "ecr" {
namespace = var.namespace # also used for creating a Kubernetes ConfigMap
environment_name = var.environment
infrastructure_support = var.infrastructure_support
}
}
58 changes: 55 additions & 3 deletions test/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,60 @@
module github.com/ministryofjustice/cloud-platform-terraform-ecr-credentials/test

go 1.15
go 1.21.6

require (
github.com/gruntwork-io/terratest v0.30.23
github.com/magiconair/properties v1.8.4
github.com/gruntwork-io/terratest v0.46.11
github.com/magiconair/properties v1.8.7
)

require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.19.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.13.0 // indirect
cloud.google.com/go/storage v1.28.1 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.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/davecgh/go-spew v1.1.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.1 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hcl/v2 v2.9.1 // indirect
github.com/hashicorp/terraform-json v0.13.0 // indirect
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // 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/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/tmccombs/hcl2json v0.3.3 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/zclconf/go-cty v1.9.1 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.114.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 0386403

Please sign in to comment.