core: Allow unknown values as variable outputs in EvalWriteOutput

At the moment this must be handled as a special case because we're still
using the old representation of output state, but we do still need to
handle this so that unknown values can properly pass between modules
during validate and plan.
This commit is contained in:
Martin Atkins 2018-05-11 15:34:58 -07:00
parent d5fda47751
commit 0b4ac6d9e3
1 changed files with 11 additions and 0 deletions

View File

@ -130,6 +130,17 @@ func (n *EvalWriteOutput) Eval(ctx EvalContext) (interface{}, error) {
Sensitive: n.Sensitive,
Value: valueTyped,
}
case !val.IsWhollyKnown():
// While we're still using our existing state format, we can't represent
// partially-unknown values properly, so we'll just stub the whole
// thing out.
// FIXME: After the state format is revised, remove this special case
// and just store the unknown value directly.
mod.Outputs[n.Addr.Name] = &OutputState{
Type: "unknown",
Sensitive: n.Sensitive,
Value: hcl2shim.UnknownVariableValue,
}
default:
return nil, fmt.Errorf("output %s is not a valid type (%s)", n.Addr.Name, ty.FriendlyName())
}