terraform: computed outputs
This commit is contained in:
parent
de6827b3ed
commit
32e714c41d
|
@ -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")
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue