From 90138825a29e85b797f3e94759118d3f3cc25e72 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 16 Jan 2015 10:22:20 -0800 Subject: [PATCH] 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. --- CHANGELOG.md | 2 ++ command/apply.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17298cae0..3a7fcbfa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ BUG FIXES: * core: Fix crash that could occur when there are exactly zero providers installed on a system. [GH-786] * 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] PLUGIN CHANGES: diff --git a/command/apply.go b/command/apply.go index e7f92bbdf..153ae3a63 100644 --- a/command/apply.go +++ b/command/apply.go @@ -53,6 +53,7 @@ func (c *ApplyCommand) Run(args []string) int { } var configPath string + maybeInit := true args = cmdFlags.Args() if len(args) > 1 { 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] } else { configPath = pwd + maybeInit = false } // Prepare the extra hooks to count resources countHook := new(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. if detected, err := module.Detect(configPath, pwd); err != nil { c.Ui.Error(fmt.Sprintf(