Skip to content

Commit

Permalink
Merge pull request #8 from confusdcodr/spotchecks
Browse files Browse the repository at this point in the history
Add dependabot configurations, fix Makefile, and update editorconfig
  • Loading branch information
confusdcodr authored Sep 19, 2019
2 parents 1383756 + 2b52faf commit fafac98
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.0
current_version = 1.0.1
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
12 changes: 12 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ update_configs:
- package_manager: "terraform"
directory: "/"
update_schedule: "daily"

- package_manager: "terraform"
directory: "/tests/baseline"
update_schedule: "daily"

- package_manager: "terraform"
directory: "/tests/no_cloudtrail"
update_schedule: "daily"

- package_manager: "go:modules"
directory: "/tests"
update_schedule: "daily"
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ insert_final_newline = true
indent_style = space
indent_size = 2
charset = utf-8
tab_width = 4

[*.md]
trim_trailing_whitespace = false

[*.py]
indent_size = 4

[go.mod]
indent_style = tab
indent_size = 1

[*.go]
indent_style = tab
indent_size = 1

[Makefile]
indent_style = tab
indent_size = 1
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### 1.0.1

**Released**: 2019.09.11

**Commit Delta**: [Change from 1.0.0 release](https://github.com/plus3it/terraform-aws-tardigrade-cloudtrail/compare/1.0.0...1.0.1)

**Summary**:

* Add additional dependabot configurations
* Fix makefile
* Add go modules configuration

### 1.0.0

**Released**: 2019.09.11

**Commit Delta**: [Change from 0.0.0 release](https://github.com/plus3it/terraform-aws-tardigrade-cloudtrail/compare/0.0.0...1.0.0)

**Summary**:

* Upgrade to terraform 0.12.x
* Add test cases

### 0.0.0

**Commit Delta**: N/A
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ docs/generate: | guard/program/terraform-docs tfdocs-awk/install
cat $(README_PARTS) > $(README_FILE)
@ echo "[$@]: Documentation files creation complete!"

dep/install: guard/program/curl
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
terratest/install: | guard/program/go
cd tests && go mod init terraform-aws-tardigrade-cloudtrail/tests
cd tests && go build ./...
cd tests && go mod tidy

terratest/install: | guard/program/go guard/program/dep
cd tests && dep ensure

terratest/test: | guard/program/go guard/program/dep
terratest/test: | guard/program/go
cd tests && go test -timeout 20m

test: terratest/test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Creates an AWS Cloudtrail

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| cloudtrail\_bucket | Name of S3 bucket to send CloudTrail logs; bucket must already exist | string | `""` | no |
| cloudtrail\_name | Name of the trail to create | string | `""` | no |
| cloudtrail\_bucket | Name of S3 bucket to send CloudTrail logs; bucket must already exist | string | `"null"` | no |
| cloudtrail\_name | Name of the trail to create | string | `"null"` | no |
| create\_cloudtrail | Controls whether to create the CloudTrail | string | `"true"` | no |
| tags | A map of tags to add to the cloudtrail resource | map(string) | `<map>` | no |

Expand Down
11 changes: 11 additions & 0 deletions tests/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module terraform-aws-tardigrade-cloudtrail/tests

go 1.13

require (
github.com/gruntwork-io/terratest v0.19.0
github.com/magiconair/properties v1.8.1 // indirect
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 // indirect
golang.org/x/net v0.0.0-20190918130420-a8b05e9114ab // indirect
)
25 changes: 25 additions & 0 deletions tests/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gruntwork-io/terratest v0.19.0 h1:LZjT4bDUzJW1M0KUw3mQIviWmg4INkNDpuKGask9UUM=
github.com/gruntwork-io/terratest v0.19.0/go.mod h1:NjUn6YXA5Skxt8Rs20t3isYx5Rl+EgvGB8/+RRXddqk=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU=
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190918130420-a8b05e9114ab h1:h5tBRKZ1aY/bo6GNqe/4zWC8GkaLOFQ5wPKIOQ0i2sA=
golang.org/x/net v0.0.0-20190918130420-a8b05e9114ab/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
68 changes: 34 additions & 34 deletions tests/module_test.go
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package testing

import (
"io/ioutil"
"log"
"os"
"testing"
"io/ioutil"
"log"
"os"
"testing"

"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/gruntwork-io/terratest/modules/terraform"
)

func TestModule(t *testing.T) {
files, err := ioutil.ReadDir("./")

if err != nil {
log.Fatal(err)
}

for _, f := range files {
// look for directories with test cases in it
if f.IsDir() && f.Name() != "vendor" {
investigateDirectory(t, f)
}
}
files, err := ioutil.ReadDir("./")

if err != nil {
log.Fatal(err)
}

for _, f := range files {
// look for directories with test cases in it
if f.IsDir() && f.Name() != "vendor" {
investigateDirectory(t, f)
}
}
}

func investigateDirectory(t *testing.T, directory os.FileInfo) {
// check if a prereq directory exists
prereqDir := directory.Name() + "/prereq/"
if _, err := os.Stat(prereqDir); err == nil {
prereqOptions := createTerraformOptions(prereqDir)
defer terraform.Destroy(t, prereqOptions)
terraform.InitAndApply(t, prereqOptions)
}

// run terraform code for test case
terraformOptions := createTerraformOptions(directory.Name())
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
// check if a prereq directory exists
prereqDir := directory.Name() + "/prereq/"
if _, err := os.Stat(prereqDir); err == nil {
prereqOptions := createTerraformOptions(prereqDir)
defer terraform.Destroy(t, prereqOptions)
terraform.InitAndApply(t, prereqOptions)
}

// run terraform code for test case
terraformOptions := createTerraformOptions(directory.Name())
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
}

func createTerraformOptions(directory string) *terraform.Options {
terraformOptions := &terraform.Options{
TerraformDir: directory,
NoColor: true,
}
terraformOptions := &terraform.Options{
TerraformDir: directory,
NoColor: true,
}

return terraformOptions
return terraformOptions
}
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ variable "create_cloudtrail" {
variable "cloudtrail_name" {
description = "Name of the trail to create"
type = string
default = ""
default = null
}

variable "cloudtrail_bucket" {
description = "Name of S3 bucket to send CloudTrail logs; bucket must already exist"
type = string
default = ""
default = null
}

variable "tags" {
Expand Down

0 comments on commit fafac98

Please sign in to comment.