diff --git a/command/apply.go b/command/apply.go index 3cbe61358..46da4a67b 100644 --- a/command/apply.go +++ b/command/apply.go @@ -95,15 +95,15 @@ func (c *ApplyCommand) Run(args []string) int { return 1 } - diff, err := tf.Diff(state) + _, err = tf.Plan(state) if err != nil { - c.Ui.Error(fmt.Sprintf("Error running diff: %s", err)) + c.Ui.Error(fmt.Sprintf("Error running plan: %s", err)) return 1 } - state, err = tf.Apply(state, diff) + state, err = tf.Apply(state, nil) if err != nil { - c.Ui.Error(fmt.Sprintf("Error applying diff: %s", err)) + c.Ui.Error(fmt.Sprintf("Error applying plan: %s", err)) return 1 } diff --git a/command/diff.go b/command/plan.go similarity index 76% rename from command/diff.go rename to command/plan.go index e7da81df8..e72e894c6 100644 --- a/command/diff.go +++ b/command/plan.go @@ -11,17 +11,17 @@ import ( "github.com/mitchellh/cli" ) -// DiffCommand is a Command implementation that compares a Terraform +// PlanCommand is a Command implementation that compares a Terraform // configuration to an actual infrastructure and shows the differences. -type DiffCommand struct { +type PlanCommand struct { TFConfig *terraform.Config Ui cli.Ui } -func (c *DiffCommand) Run(args []string) int { +func (c *PlanCommand) Run(args []string) int { var statePath string - cmdFlags := flag.NewFlagSet("diff", flag.ContinueOnError) + cmdFlags := flag.NewFlagSet("plan", flag.ContinueOnError) cmdFlags.StringVar(&statePath, "state", "", "path") cmdFlags.Usage = func() { c.Ui.Error(c.Help()) } if err := cmdFlags.Parse(args); err != nil { @@ -31,7 +31,7 @@ func (c *DiffCommand) Run(args []string) int { args = cmdFlags.Args() if len(args) != 1 { c.Ui.Error( - "The diff command expects only one argument with the path\n" + + "The plan command expects only one argument with the path\n" + "to a Terraform configuration.\n") cmdFlags.Usage() return 1 @@ -69,24 +69,24 @@ func (c *DiffCommand) Run(args []string) int { return 1 } - diff, err := tf.Diff(state) + plan, err := tf.Plan(state) if err != nil { - c.Ui.Error(fmt.Sprintf("Error running diff: %s", err)) + c.Ui.Error(fmt.Sprintf("Error running plan: %s", err)) return 1 } - if diff.Empty() { + if plan.Diff.Empty() { c.Ui.Output("No changes. Infrastructure is up-to-date.") } else { - c.Ui.Output(strings.TrimSpace(diff.String())) + c.Ui.Output(strings.TrimSpace(plan.String())) } return 0 } -func (c *DiffCommand) Help() string { +func (c *PlanCommand) Help() string { helpText := ` -Usage: terraform diff [options] [terraform.tf] +Usage: terraform plan [options] [terraform.tf] Shows the differences between the Terraform configuration and the actual state of an infrastructure. @@ -100,6 +100,6 @@ Options: return strings.TrimSpace(helpText) } -func (c *DiffCommand) Synopsis() string { +func (c *PlanCommand) Synopsis() string { return "Show changes between Terraform config and infrastructure" } diff --git a/command/diff_test.go b/command/plan_test.go similarity index 90% rename from command/diff_test.go rename to command/plan_test.go index 77e2262e7..bb790ec2d 100644 --- a/command/diff_test.go +++ b/command/plan_test.go @@ -10,16 +10,16 @@ import ( "github.com/mitchellh/cli" ) -func TestDiff_noState(t *testing.T) { +func TestPlan_noState(t *testing.T) { p := testProvider() ui := new(cli.MockUi) - c := &DiffCommand{ + c := &PlanCommand{ TFConfig: testTFConfig(p), Ui: ui, } args := []string{ - testFixturePath("diff"), + testFixturePath("plan"), } if code := c.Run(args); code != 0 { t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) @@ -34,7 +34,7 @@ func TestDiff_noState(t *testing.T) { } } -func TestDiff_state(t *testing.T) { +func TestPlan_state(t *testing.T) { // Write out some prior state tf, err := ioutil.TempFile("", "tf") if err != nil { @@ -60,14 +60,14 @@ func TestDiff_state(t *testing.T) { p := testProvider() ui := new(cli.MockUi) - c := &DiffCommand{ + c := &PlanCommand{ TFConfig: testTFConfig(p), Ui: ui, } args := []string{ "-state", statePath, - testFixturePath("diff"), + testFixturePath("plan"), } if code := c.Run(args); code != 0 { t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) diff --git a/commands.go b/commands.go index 347ca9da3..9fddde33c 100644 --- a/commands.go +++ b/commands.go @@ -30,8 +30,8 @@ func init() { }, nil }, - "diff": func() (cli.Command, error) { - return &command.DiffCommand{ + "plan": func() (cli.Command, error) { + return &command.PlanCommand{ TFConfig: &TFConfig, Ui: ui, }, nil