mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
core: EvalWriteOutput discard unknown values before writing state
The state only deals in wholly-known values, so here we null out any unknowns for storage in state. This is okay because we subsequently write the original, possibly-unknown value into the plan and the expression evaluator will prefer to use this if present, allowing the unknown values to properly propagate into other expressions in the calling module.
This commit is contained in:
parent
a709b9f07a
commit
ace46e9669
@ -68,7 +68,11 @@ func (n *EvalWriteOutput) Eval(ctx EvalContext) (interface{}, error) {
|
||||
}
|
||||
|
||||
if val.IsKnown() && !val.IsNull() {
|
||||
state.SetOutputValue(addr, val, n.Sensitive)
|
||||
// The state itself doesn't represent unknown values, so we null them
|
||||
// out here and then we'll save the real unknown value in the planned
|
||||
// changeset below, if we have one on this graph walk.
|
||||
stateVal := cty.UnknownAsNull(val)
|
||||
state.SetOutputValue(addr, stateVal, n.Sensitive)
|
||||
} else {
|
||||
state.RemoveOutputValue(addr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user