diff --git a/cmd/migrate_command_test.go b/cmd/migrate_command_test.go index 45682cf9..a7c82dd4 100644 --- a/cmd/migrate_command_test.go +++ b/cmd/migrate_command_test.go @@ -111,7 +111,7 @@ provider "azurerm" { ErrorWriter: os.Stderr, }, } - p, err := terraform.Plan() + p, err := terraform.Plan(nil) if err != nil { log.Fatal(err) } @@ -182,7 +182,7 @@ provider "azurerm" { } // check no plan-diff - plan, err := terraform.Plan() + plan, err := terraform.Plan(nil) if err != nil { t.Fatal(err) } diff --git a/cmd/plan_command.go b/cmd/plan_command.go index 0ca685f5..06897269 100644 --- a/cmd/plan_command.go +++ b/cmd/plan_command.go @@ -80,7 +80,7 @@ func (c *PlanCommand) Synopsis() string { func (c *PlanCommand) Plan(terraform *tf.Terraform, isPlanOnly bool) []types.AzureResource { // get azapi resource from state log.Printf("[INFO] running terraform plan...") - p, err := terraform.Plan(c.varFile) + p, err := terraform.Plan(&c.varFile) if err != nil { log.Fatal(err) } diff --git a/tf/terraform.go b/tf/terraform.go index 6850cf94..290701d2 100644 --- a/tf/terraform.go +++ b/tf/terraform.go @@ -69,10 +69,10 @@ func (t *Terraform) Show() (*tfjson.State, error) { return t.exec.Show(context.TODO()) } -func (t *Terraform) Plan(varFile string) (*tfjson.Plan, error) { +func (t *Terraform) Plan(varFile *string) (*tfjson.Plan, error) { planOptions := []tfexec.PlanOption{tfexec.Out(planfile)} - if varFile != "" { - planOptions = append(planOptions, tfexec.VarFile(varFile)) + if varFile != nil && *varFile != "" { + planOptions = append(planOptions, tfexec.VarFile(*varFile)) } _, err := t.exec.Plan(context.TODO(), planOptions...) if err != nil {