terraform: fix outputs on destroy
This commit is contained in:
parent
bd0c3b12cb
commit
1c713878b0
|
@ -3839,7 +3839,6 @@ func TestContext2Apply_destroy(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestContext2Apply_destroyOutputs(t *testing.T) {
|
||||
m := testModule(t, "apply-destroy-outputs")
|
||||
h := new(HookRecordApplyOrder)
|
||||
|
@ -3880,7 +3879,6 @@ func TestContext2Apply_destroyOutputs(t *testing.T) {
|
|||
t.Fatalf("bad: %#v", mod)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestContext2Apply_destroyOrphan(t *testing.T) {
|
||||
m := testModule(t, "apply-error")
|
||||
|
|
|
@ -10,17 +10,20 @@ import (
|
|||
// for the given name to the current state.
|
||||
type EvalWriteOutput struct {
|
||||
Name string
|
||||
Value EvalNode
|
||||
Value *config.RawConfig
|
||||
}
|
||||
|
||||
func (n *EvalWriteOutput) Args() ([]EvalNode, []EvalType) {
|
||||
return []EvalNode{n.Value}, []EvalType{EvalTypeConfig}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
func (n *EvalWriteOutput) Eval(
|
||||
ctx EvalContext, args []interface{}) (interface{}, error) {
|
||||
cfg := args[0].(*ResourceConfig)
|
||||
cfg, err := ctx.Interpolate(n.Value, nil)
|
||||
if err != nil {
|
||||
// Ignore it
|
||||
}
|
||||
|
||||
state, lock := ctx.State()
|
||||
if state == nil {
|
||||
|
@ -38,12 +41,16 @@ func (n *EvalWriteOutput) Eval(
|
|||
}
|
||||
|
||||
// Get the value from the config
|
||||
valueRaw, ok := cfg.Get("value")
|
||||
if !ok {
|
||||
valueRaw = ""
|
||||
}
|
||||
if cfg.IsComputed("value") {
|
||||
valueRaw = config.UnknownVariableValue
|
||||
var valueRaw interface{} = config.UnknownVariableValue
|
||||
if cfg != nil {
|
||||
var ok bool
|
||||
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
|
||||
|
|
|
@ -124,9 +124,13 @@ func (n *GraphNodeConfigOutput) DependentOn() []string {
|
|||
func (n *GraphNodeConfigOutput) EvalTree() EvalNode {
|
||||
return &EvalOpFilter{
|
||||
Ops: []walkOperation{walkRefresh, walkPlan, walkApply},
|
||||
Node: &EvalWriteOutput{
|
||||
Name: n.Output.Name,
|
||||
Value: &EvalInterpolate{Config: n.Output.RawConfig},
|
||||
Node: &EvalSequence{
|
||||
Nodes: []EvalNode{
|
||||
&EvalWriteOutput{
|
||||
Name: n.Output.Name,
|
||||
Value: n.Output.RawConfig,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue