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