From 10b5661bc31d731c0cea0efd0f23541a56463d3b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 19 Sep 2014 22:35:29 -0600 Subject: [PATCH] terraform: planning tainted resources works --- terraform/context.go | 7 ++++++- terraform/graph.go | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index eb12e102dd..4c7a6ae0d9 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -759,6 +759,11 @@ func (c *Context) planWalkFn(result *Plan) depgraph.WalkFunc { result.init() cb := func(r *Resource) error { + if r.Tainted && r.TaintedIndex > -1 { + // No-op this. We somewhat magically diff this later. + return nil + } + var diff *InstanceDiff is := r.State.Primary @@ -895,7 +900,7 @@ func (c *Context) planDestroyWalkFn(result *Plan) depgraph.WalkFunc { func (c *Context) refreshWalkFn() depgraph.WalkFunc { cb := func(r *Resource) error { is := r.State.Primary - if r.Tainted { + if r.Tainted && r.TaintedIndex > -1 { is = r.State.Tainted[r.TaintedIndex] } diff --git a/terraform/graph.go b/terraform/graph.go index d303fcc812..2a2ad496c1 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -271,10 +271,11 @@ func graphAddConfigResources( Type: r.Type, Config: r, Resource: &Resource{ - Id: name, - State: state, - Config: NewResourceConfig(r.RawConfig), - Tainted: len(state.Tainted) > 0, + Id: name, + State: state, + Config: NewResourceConfig(r.RawConfig), + Tainted: len(state.Tainted) > 0, + TaintedIndex: -1, }, }, }