Skip to content

Commit

Permalink
command/*: only Plan on the Apply
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jul 14, 2014
1 parent ad3c059 commit 6c8c09c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion command/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion command/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions command/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion command/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion command/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c8c09c

Please sign in to comment.