From 843cfbe8adcd23ba015a262bb4158e977cef0d09 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 13 Feb 2015 08:50:59 -0800 Subject: [PATCH] terraform: tainted apply --- terraform/context_test.go | 6 ++--- terraform/transform_tainted.go | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/terraform/context_test.go b/terraform/context_test.go index 06c9c040e..71a74f0a8 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -3074,8 +3074,7 @@ func TestContext2Apply_countDecreaseToOne(t *testing.T) { } } -/* -func TestContextApply_countTainted(t *testing.T) { +func TestContext2Apply_countTainted(t *testing.T) { m := testModule(t, "apply-count-tainted") p := testProvider("aws") p.DiffFn = testDiffFn @@ -3100,7 +3099,7 @@ func TestContextApply_countTainted(t *testing.T) { }, }, } - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -3124,6 +3123,7 @@ func TestContextApply_countTainted(t *testing.T) { } } +/* func TestContextApply_countVariable(t *testing.T) { m := testModule(t, "apply-count-variable") p := testProvider("aws") diff --git a/terraform/transform_tainted.go b/terraform/transform_tainted.go index c6bbdb2b6..b0b9e0d0a 100644 --- a/terraform/transform_tainted.go +++ b/terraform/transform_tainted.go @@ -102,5 +102,50 @@ func (n *graphNodeTaintedResource) EvalTree() EvalNode { }, }) + // Apply + var provider ResourceProvider + var diff *InstanceDiff + seq.Nodes = append(seq.Nodes, &EvalOpFilter{ + Ops: []walkOperation{walkApply}, + Node: &EvalSequence{ + Nodes: []EvalNode{ + &EvalGetProvider{ + Name: n.ProvidedBy()[0], + Output: &provider, + }, + &EvalReadState{ + Name: n.ResourceName, + Tainted: true, + TaintedIndex: n.Index, + Output: &state, + }, + &EvalDiffDestroy{ + Info: info, + State: &EvalReadState{ + Name: n.ResourceName, + Tainted: true, + TaintedIndex: n.Index, + }, + Output: &diff, + }, + &EvalApply{ + Info: info, + State: &state, + Diff: &diff, + Provider: &provider, + Output: &state, + }, + &EvalWriteState{ + Name: n.ResourceName, + ResourceType: n.ResourceType, + Dependencies: n.DependentOn(), + State: &state, + Tainted: true, + TaintedIndex: n.Index, + }, + }, + }, + }) + return seq }