From 5596ee7f53b210a7628c5eadff51a273f2f88aac Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 15 Oct 2014 20:32:19 -0700 Subject: [PATCH] terraform: don't panic if no state in Walk return [GH-403] --- CHANGELOG.md | 3 +++ terraform/context.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1c31d14845c..f36c7b8a6c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## 0.3.1 (unreleased) +BUG FIXES: + * core: Remove panic case when applying with a plan that generates no + new state. [GH-403] ## 0.3.0 (October 14, 2014) diff --git a/terraform/context.go b/terraform/context.go index 82e82de597cc..5dff77d403da 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -517,13 +517,13 @@ func (c *walkContext) Walk() error { // Likewise, if we have no resources in our state, we're done. This // guards against the case that we destroyed. mod := c.Context.state.ModuleByPath(c.Path) + if mod == nil { + return nil + } if c.Operation == walkApply { // On Apply, we prune so that we don't do outputs if we destroyed mod.prune() } - if mod == nil || len(mod.Resources) == 0 { - return nil - } if len(mod.Resources) == 0 { mod.Outputs = nil return nil