Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding suport for -var-file and -target argument #201

Merged
merged 18 commits into from Feb 17, 2019

Conversation

aclowkey
Copy link
Contributor

@aclowkey aclowkey commented Nov 29, 2018

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks! Could you add some sort of test for this? E.g., deploy one of the existing examples by creating and pass some required params via a var file?

@aclowkey
Copy link
Contributor Author

Any tips on how to make it simple as possible?

@aclowkey aclowkey changed the title Adding suport for -var-file argument Adding suport for -var-file and -target argument Nov 29, 2018
@aclowkey
Copy link
Contributor Author

What do you think ? I didn't test yet, but Ill do as soon as I can.

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test looks perfect, thanks! Let me know once you've run it and confirmed it works, and this is ready to merge.

modules/terraform/cmd.go Outdated Show resolved Hide resolved
test/terraform_basic_example_test.go Outdated Show resolved Hide resolved
@aclowkey
Copy link
Contributor Author

aclowkey commented Dec 1, 2018

I'm struggling with running the tests :S

For some reason go isn't aware of the change in the files..

ac@ac-PC:~/go/src/github.com/gruntwork-io/terratest/test$ go test -v -run TestTerraformBasicExample
# github.com/gruntwork-io/terratest/test
./terraform_basic_example_test.go:25:11: unknown field 'VarFiles' in struct literal of type terraform.Options
FAIL	github.com/gruntwork-io/terratest/test [build failed]

@brikis98
Copy link
Member

brikis98 commented Dec 2, 2018

That's weird. Did you set up your GOPATH correctly?

@aclowkey
Copy link
Contributor Author

aclowkey commented Dec 2, 2018

I tried on a different machine and it worked!. I think it's because I had a symbolic link to a different directory.. I guess go doesn't like that.

Now the test pass, I need to add a test for -target now

@brikis98
Copy link
Member

brikis98 commented Dec 3, 2018

Are all the tests added and passing now?

@aclowkey
Copy link
Contributor Author

aclowkey commented Dec 3, 2018 via email

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is just about ready to merge. Just a couple last minor items. Thanks!

// FormatTerraformArgs will format multiple args with the arg name (e.g. arg-file a arg-file b)
func FormatTerraformArgs(argName string, args []string) []string {
argsList := []string{}
for _, varFile := range args {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argValue is probably a better name here than varFile

@@ -19,6 +23,15 @@ func FormatTerraformVarsAsArgs(vars map[string]interface{}) []string {
return formatTerraformArgs(vars, "-var")
}

// FormatTerraformArgs will format multiple args with the arg name (e.g. arg-file a arg-file b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more realistic example might help explain what this method does. E.g.,

FormatTerraformArgs("-var-file", []string{"foo.tfvars", "bar.tfvars"}) returns "-var-file foo.tfvars -var-file bar.tfvars"

Targets: []string{"local_file.example"},

// Use the var files
VarFiles: []string{"varfile.tfvars"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, terraform_basic_example_test.go should be, well, a basic example intended to provide simple example code for Terratest newbies. I think Targets and VarFiles and the corresponding checks may be a little too complex for someone just starting out. Perhaps move this example + corresponding test code to a different example?

@brikis98
Copy link
Member

@aclowkey What is the latest status with this. Have all comments been resolved?

@brikis98 brikis98 mentioned this pull request Jan 17, 2019
@aclowkey
Copy link
Contributor Author

aclowkey commented Jan 17, 2019

No. The only unresolved issue is that of having it in another example. I will comment about it
EDIT: Ok. So I will create a similar example, just with var-files and target, and leave the example to be basic

@kurtmaile
Copy link

Will this be merged soon by any chance?

@brikis98
Copy link
Member

@aclowkey Did you add all tests/examples you were planning to?

@aclowkey
Copy link
Contributor Author

aclowkey commented Feb 17, 2019 via email

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks! I'll merge this now and let the tests run. If they pass, I'll issue a new release.

@brikis98 brikis98 merged commit 5c24de4 into gruntwork-io:master Feb 17, 2019
@brikis98
Copy link
Member

https://github.com/gruntwork-io/terratest/releases/tag/v0.13.27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants