mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 17:01:04 -06:00
73053eb5ef
Some of the objects that are referencable from expressions are transient values computed only during a graph walk, and not persisted in state. In order to support arbitrary evaluation of expressions, such as in the "terraform console" CLI command, it's necessary to be able to evaluate these values before we start evaluating. This new Eval method achieves this by performing a special graph walk that ignores resources (except for dependency resolution) and just focuses on evaluating all of these transient values, before returning an evaluation scope that can then resolve expressions in terms of that result. This replaces the Context.Interpolator method, which was fraught with various issues due to it not properly priming the state before evaluating.
21 lines
513 B
Go
21 lines
513 B
Go
package terraform
|
|
|
|
// NodeEvalableProvider represents a provider during an "eval" walk.
|
|
// This special provider node type just initializes a provider and
|
|
// fetches its schema, without configuring it or otherwise interacting
|
|
// with it.
|
|
type NodeEvalableProvider struct {
|
|
*NodeAbstractProvider
|
|
}
|
|
|
|
// GraphNodeEvalable
|
|
func (n *NodeEvalableProvider) EvalTree() EvalNode {
|
|
addr := n.Addr
|
|
relAddr := addr.ProviderConfig
|
|
|
|
return &EvalInitProvider{
|
|
TypeName: relAddr.Type,
|
|
Addr: addr.ProviderConfig,
|
|
}
|
|
}
|