mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
22 lines
345 B
Go
22 lines
345 B
Go
package terraform
|
|
|
|
// EvalIf is an EvalNode that is a conditional.
|
|
type EvalIf struct {
|
|
If func(EvalContext) (bool, error)
|
|
Node EvalNode
|
|
}
|
|
|
|
// TODO: test
|
|
func (n *EvalIf) Eval(ctx EvalContext) (interface{}, error) {
|
|
yes, err := n.If(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if yes {
|
|
return EvalRaw(n.Node, ctx)
|
|
}
|
|
|
|
return nil, nil
|
|
}
|