From 6c8c09c784eed77bfcb75f49d03a4b4938eee6ad Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 14 Jul 2014 11:48:03 -0700 Subject: [PATCH] command/*: only Plan on the Apply --- command/apply.go | 2 +- command/graph.go | 2 +- command/meta.go | 8 +++++--- command/plan.go | 2 +- command/refresh.go | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/command/apply.go b/command/apply.go index 0276d984755e..0ca22b73f9f9 100644 --- a/command/apply.go +++ b/command/apply.go @@ -64,7 +64,7 @@ func (c *ApplyCommand) Run(args []string) int { } // Build the context based on the arguments given - ctx, err := c.Context(configPath, planStatePath) + ctx, err := c.Context(configPath, planStatePath, true) if err != nil { c.Ui.Error(err.Error()) return 1 diff --git a/command/graph.go b/command/graph.go index 42e87da498d8..68c8bddbf718 100644 --- a/command/graph.go +++ b/command/graph.go @@ -40,7 +40,7 @@ func (c *GraphCommand) Run(args []string) int { } } - ctx, err := c.Context(path, "") + ctx, err := c.Context(path, "", false) if err != nil { c.Ui.Error(fmt.Sprintf("Error loading Terraform: %s", err)) return 1 diff --git a/command/meta.go b/command/meta.go index 3bafdb7a8445..d8ee72293176 100644 --- a/command/meta.go +++ b/command/meta.go @@ -30,7 +30,7 @@ func (m *Meta) Colorize() *colorstring.Colorize { // Context returns a Terraform Context taking into account the context // options used to initialize this meta configuration. -func (m *Meta) Context(path, statePath string) (*terraform.Context, error) { +func (m *Meta) Context(path, statePath string, doPlan bool) (*terraform.Context, error) { opts := m.contextOpts() // First try to just read the plan directly from the path given. @@ -84,8 +84,10 @@ func (m *Meta) Context(path, statePath string) (*terraform.Context, error) { opts.State = state ctx := terraform.NewContext(opts) - if _, err := ctx.Plan(nil); err != nil { - return nil, fmt.Errorf("Error running plan: %s", err) + if doPlan { + if _, err := ctx.Plan(nil); err != nil { + return nil, fmt.Errorf("Error running plan: %s", err) + } } return ctx, nil diff --git a/command/plan.go b/command/plan.go index 44790f72bf66..7808c3879cf0 100644 --- a/command/plan.go +++ b/command/plan.go @@ -59,7 +59,7 @@ func (c *PlanCommand) Run(args []string) int { } } - ctx, err := c.Context(path, statePath) + ctx, err := c.Context(path, statePath, false) if err != nil { c.Ui.Error(err.Error()) return 1 diff --git a/command/refresh.go b/command/refresh.go index 256bf70dd590..39b27530ac39 100644 --- a/command/refresh.go +++ b/command/refresh.go @@ -78,7 +78,7 @@ func (c *RefreshCommand) Run(args []string) int { } // Build the context based on the arguments given - ctx, err := c.Context(configPath, statePath) + ctx, err := c.Context(configPath, statePath, false) if err != nil { c.Ui.Error(err.Error()) return 1