0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-06-02 18:39:41 +02:00

Add -var-file and -var to destroy operation ; Go fmt the code

This commit is contained in:
Luis Silva 2018-07-27 08:32:19 +01:00
parent 08402ee4d0
commit 4ebb830452
3 changed files with 12 additions and 5 deletions

View File

@ -255,6 +255,13 @@ 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, "-var-file", fmt.Sprintf("%s", v))
}
for k, v := range config.Vars {
args = append(args, "-var")
args = append(args, fmt.Sprintf("%s=%s", k, v))
}
if config.Parallelism > 0 {
args = append(args, fmt.Sprintf("-parallelism=%d", config.Parallelism))
}

View File

@ -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",

View File

@ -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
}