From 32e714c41dcfc4a311e555962cc521c2bde7f739 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 11 Feb 2015 22:38:38 -0800 Subject: [PATCH] terraform: computed outputs --- terraform/context_test.go | 6 +++--- terraform/eval_output.go | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/terraform/context_test.go b/terraform/context_test.go index 80e64f353..c678efaaa 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -419,12 +419,11 @@ func TestContext2Plan_moduleVar(t *testing.T) { } } -/* -func TestContextPlan_moduleVarComputed(t *testing.T) { +func TestContext2Plan_moduleVarComputed(t *testing.T) { m := testModule(t, "plan-module-var-computed") p := testProvider("aws") p.DiffFn = testDiffFn - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -443,6 +442,7 @@ func TestContextPlan_moduleVarComputed(t *testing.T) { } } +/* func TestContextPlan_nil(t *testing.T) { m := testModule(t, "plan-nil") p := testProvider("aws") diff --git a/terraform/eval_output.go b/terraform/eval_output.go index cd82d5ce0..dedef0532 100644 --- a/terraform/eval_output.go +++ b/terraform/eval_output.go @@ -2,6 +2,8 @@ package terraform import ( "fmt" + + "github.com/hashicorp/terraform/config" ) // EvalWriteOutput is an EvalNode implementation that writes the output @@ -18,7 +20,7 @@ func (n *EvalWriteOutput) Args() ([]EvalNode, []EvalType) { // TODO: test func (n *EvalWriteOutput) Eval( ctx EvalContext, args []interface{}) (interface{}, error) { - config := args[0].(*ResourceConfig) + cfg := args[0].(*ResourceConfig) state, lock := ctx.State() if state == nil { @@ -36,10 +38,13 @@ func (n *EvalWriteOutput) Eval( } // Get the value from the config - valueRaw, ok := config.Get("value") + valueRaw, ok := cfg.Get("value") if !ok { valueRaw = "" } + if cfg.IsComputed("value") { + valueRaw = config.UnknownVariableValue + } // If it is a list of values, get the first one if list, ok := valueRaw.([]interface{}); ok {