command: Run validation before asking for input. Fixes #602

This commit is contained in:
Armon Dadgar 2014-12-08 18:32:03 -08:00
parent 57fd308e93
commit 5b745e5d46
3 changed files with 9 additions and 9 deletions

View File

@ -133,15 +133,15 @@ func (c *ApplyCommand) Run(args []string) int {
return 1
}
}
if !validateContext(ctx, c.Ui) {
return 1
}
if !planned {
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
return 1
}
}
if !validateContext(ctx, c.Ui) {
return 1
}
// Create a backup of the state before updating
if backupPath != "-" && c.state != nil {

View File

@ -75,11 +75,11 @@ func (c *PlanCommand) Run(args []string) int {
c.Ui.Error(err.Error())
return 1
}
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
if !validateContext(ctx, c.Ui) {
return 1
}
if !validateContext(ctx, c.Ui) {
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
return 1
}

View File

@ -92,11 +92,11 @@ func (c *RefreshCommand) Run(args []string) int {
c.Ui.Error(err.Error())
return 1
}
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
if !validateContext(ctx, c.Ui) {
return 1
}
if !validateContext(ctx, c.Ui) {
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
return 1
}