Skip to content

Commit

Permalink
rename field
Browse files Browse the repository at this point in the history
  • Loading branch information
chilledornaments committed Dec 15, 2022
1 parent 56a2e8d commit cdc0dc4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/terraform/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func FormatArgs(options *Options, args ...string) []string {
terraformArgs = append(terraformArgs, args...)

if includeVars {
if options.SetVarArgsLast {
if options.SetVarsAfterVarFiles {
terraformArgs = append(terraformArgs, FormatTerraformArgs("-var-file", options.VarFiles)...)
terraformArgs = append(terraformArgs, FormatTerraformVarsAsArgs(options.Vars)...)
} else {
Expand Down
14 changes: 7 additions & 7 deletions modules/terraform/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,22 @@ func TestFormatArgsAppliesLockCorrectly(t *testing.T) {
}
}

func TestFormatSetVarArgsLastFormatsCorrectly(t *testing.T) {
func TestFormatSetVarsAfterVarFilesFormatsCorrectly(t *testing.T) {
t.Parallel()

testCases := []struct {
command []string
vars map[string]interface{}
varFiles []string
setVarArgsLast bool
expected []string
command []string
vars map[string]interface{}
varFiles []string
setVarsAfterVarFiles bool
expected []string
}{
{[]string{"plan"}, map[string]interface{}{"foo": "bar"}, []string{"test.tfvars"}, true, []string{"plan", "-var-file", "test.tfvars", "-var", "foo=bar", "-lock=false"}},
{[]string{"plan"}, map[string]interface{}{"foo": "bar", "hello": "world"}, []string{"test.tfvars"}, true, []string{"plan", "-var-file", "test.tfvars", "-var", "foo=bar", "-var", "hello=world", "-lock=false"}},
{[]string{"plan"}, map[string]interface{}{"foo": "bar", "hello": "world"}, []string{"test.tfvars"}, false, []string{"plan", "-var", "foo=bar", "-var", "hello=world", "-var-file", "test.tfvars", "-lock=false"}},
}

for _, testCase := range testCases {
assert.Equal(t, testCase.expected, FormatArgs(&Options{SetVarArgsLast: testCase.setVarArgsLast, Vars: testCase.vars, VarFiles: testCase.varFiles}, testCase.command...))
assert.Equal(t, testCase.expected, FormatArgs(&Options{SetVarsAfterVarFiles: testCase.setVarsAfterVarFiles, Vars: testCase.vars, VarFiles: testCase.varFiles}, testCase.command...))
}
}
2 changes: 1 addition & 1 deletion modules/terraform/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type Options struct {
Parallelism int // Set the parallelism setting for Terraform
PlanFilePath string // The path to output a plan file to (for the plan command) or read one from (for the apply command)
PluginDir string // The path of downloaded plugins to pass to the terraform init command (-plugin-dir)
SetVarArgsLast bool // Pass -var options after -var-file options to Terraform commands
SetVarsAfterVarFiles bool // Pass -var options after -var-file options to Terraform commands
}

// Clone makes a deep copy of most fields on the Options object and returns it.
Expand Down

0 comments on commit cdc0dc4

Please sign in to comment.