opentofu/terraform/eval_if.go
2015-02-19 12:08:32 -08:00

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
}