From 5b745e5d46c145cc60781540a2f3db19a99cf255 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 8 Dec 2014 18:32:03 -0800 Subject: [PATCH] command: Run validation before asking for input. Fixes #602 --- command/apply.go | 6 +++--- command/plan.go | 6 +++--- command/refresh.go | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/command/apply.go b/command/apply.go index 7a4df3971b5d..8ca8a909824d 100644 --- a/command/apply.go +++ b/command/apply.go @@ -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 { diff --git a/command/plan.go b/command/plan.go index 32ad745af20a..f4ad99d74f9c 100644 --- a/command/plan.go +++ b/command/plan.go @@ -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 } diff --git a/command/refresh.go b/command/refresh.go index 6ec2d0f8ee8a..4db0a3d23d82 100644 --- a/command/refresh.go +++ b/command/refresh.go @@ -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 }