opentofu/terraform/eval_if.go

22 lines
345 B
Go
Raw Normal View History

2015-02-13 14:05:34 -06:00
package terraform
// EvalIf is an EvalNode that is a conditional.
type EvalIf struct {
If func(EvalContext) (bool, error)
Node EvalNode
}
// TODO: test
2015-02-14 00:58:41 -06:00
func (n *EvalIf) Eval(ctx EvalContext) (interface{}, error) {
2015-02-13 14:05:34 -06:00
yes, err := n.If(ctx)
if err != nil {
return nil, err
}
if yes {
return EvalRaw(n.Node, ctx)
}
return nil, nil
}