command/*: only Plan on the Apply

pull/20/head
Mitchell Hashimoto 12 years ago
parent ad3c0593a3
commit 6c8c09c784

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

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

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

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

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

Loading…
Cancel
Save