diff --git a/plugin.go b/plugin.go index 7321c03..2d33629 100644 --- a/plugin.go +++ b/plugin.go @@ -255,6 +255,12 @@ func tfDestroy(config Config) *exec.Cmd { for _, v := range config.Targets { args = append(args, fmt.Sprintf("-target=%s", v)) } + for _, v := range config.VarFiles { + args = append(args, fmt.Sprintf("-var-file=%s", v)) + } + for k, v := range config.Vars { + args = append(args, "-var", fmt.Sprintf("%s=%s", k, v)) + } if config.Parallelism > 0 { args = append(args, fmt.Sprintf("-parallelism=%d", config.Parallelism)) } @@ -286,11 +292,10 @@ func tfPlan(config Config, destroy bool) *exec.Cmd { args = append(args, "--target", fmt.Sprintf("%s", v)) } for _, v := range config.VarFiles { - args = append(args, "-var-file", fmt.Sprintf("%s", v)) + args = append(args, fmt.Sprintf("-var-file=%s", v)) } for k, v := range config.Vars { - args = append(args, "-var") - args = append(args, fmt.Sprintf("%s=%s", k, v)) + args = append(args, "-var", fmt.Sprintf("%s=%s", k, v)) } if config.Parallelism > 0 { args = append(args, fmt.Sprintf("-parallelism=%d", config.Parallelism)) @@ -312,11 +317,10 @@ func tfValidate(config Config) *exec.Cmd { "validate", } for _, v := range config.VarFiles { - args = append(args, "-var-file", fmt.Sprintf("%s", v)) + args = append(args, fmt.Sprintf("-var-file=%s", v)) } for k, v := range config.Vars { - args = append(args, "-var") - args = append(args, fmt.Sprintf("%s=%s", k, v)) + args = append(args, "-var", fmt.Sprintf("%s=%s", k, v)) } return exec.Command( "terraform", diff --git a/plugin_test.go b/plugin_test.go index baf59c0..197d2a7 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -102,10 +102,10 @@ func TestPlugin(t *testing.T) { } tests := []struct { - name string - args args + name string + args args destroy bool - want *exec.Cmd + want *exec.Cmd }{ { "default", diff --git a/terraform.go b/terraform.go index 19ee04e..6834ddc 100644 --- a/terraform.go +++ b/terraform.go @@ -32,7 +32,7 @@ func downloadTerraform(version string) error { func downloadFile(filepath string, url string) error { // Create the file out, err := os.Create(filepath) - if err != nil { + if err != nil { return err } defer out.Close() @@ -46,7 +46,7 @@ func downloadFile(filepath string, url string) error { // Writer the body to file _, err = io.Copy(out, resp.Body) - if err != nil { + if err != nil { return err }