command/apply: don't init if no args given [GH-780]

I really don't know how to unit test this since I don't know what input
triggers this except that it has been reporting a few times in the wild.
This commit is contained in:
Mitchell Hashimoto 2015-01-16 10:22:20 -08:00
parent 91a3405e88
commit 90138825a2
2 changed files with 5 additions and 1 deletions

View File

@ -17,6 +17,8 @@ BUG FIXES:
* core: Fix crash that could occur when there are exactly zero providers * core: Fix crash that could occur when there are exactly zero providers
installed on a system. [GH-786] installed on a system. [GH-786]
* core: JSON TF configurations can configure provisioners. [GH-807] * core: JSON TF configurations can configure provisioners. [GH-807]
* command/apply: Won't try to initialize modules in some cases when
no arguments are given. [GH-780]
* provider/aws: ELB subnet change doesn't force new resource. [GH-804] * provider/aws: ELB subnet change doesn't force new resource. [GH-804]
PLUGIN CHANGES: PLUGIN CHANGES:

View File

@ -53,6 +53,7 @@ func (c *ApplyCommand) Run(args []string) int {
} }
var configPath string var configPath string
maybeInit := true
args = cmdFlags.Args() args = cmdFlags.Args()
if len(args) > 1 { if len(args) > 1 {
c.Ui.Error("The apply command expects at most one argument.") c.Ui.Error("The apply command expects at most one argument.")
@ -62,13 +63,14 @@ func (c *ApplyCommand) Run(args []string) int {
configPath = args[0] configPath = args[0]
} else { } else {
configPath = pwd configPath = pwd
maybeInit = false
} }
// Prepare the extra hooks to count resources // Prepare the extra hooks to count resources
countHook := new(CountHook) countHook := new(CountHook)
c.Meta.extraHooks = []terraform.Hook{countHook} c.Meta.extraHooks = []terraform.Hook{countHook}
if !c.Destroy { if !c.Destroy && maybeInit {
// Do a detect to determine if we need to do an init + apply. // Do a detect to determine if we need to do an init + apply.
if detected, err := module.Detect(configPath, pwd); err != nil { if detected, err := module.Detect(configPath, pwd); err != nil {
c.Ui.Error(fmt.Sprintf( c.Ui.Error(fmt.Sprintf(