diff --git a/modules/terraform/format.go b/modules/terraform/format.go index 35287d52c..7b6293a58 100644 --- a/modules/terraform/format.go +++ b/modules/terraform/format.go @@ -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 { diff --git a/modules/terraform/format_test.go b/modules/terraform/format_test.go index e87ec98c1..e82ad8e07 100644 --- a/modules/terraform/format_test.go +++ b/modules/terraform/format_test.go @@ -279,15 +279,15 @@ 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"}}, @@ -295,6 +295,6 @@ func TestFormatSetVarArgsLastFormatsCorrectly(t *testing.T) { } 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...)) } } diff --git a/modules/terraform/options.go b/modules/terraform/options.go index 5ac08a3eb..9495a6c09 100644 --- a/modules/terraform/options.go +++ b/modules/terraform/options.go @@ -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.