opentofu/terraform/eval_sequence.go

38 lines
707 B
Go
Raw Normal View History

2015-02-04 19:23:26 -06:00
package terraform
import (
"github.com/hashicorp/terraform/tfdiags"
)
2015-02-04 19:23:26 -06:00
// EvalSequence is an EvalNode that evaluates in sequence.
type EvalSequence struct {
Nodes []EvalNode
}
2015-02-14 00:58:41 -06:00
func (n *EvalSequence) Eval(ctx EvalContext) (interface{}, error) {
var diags tfdiags.Diagnostics
2015-02-14 00:58:41 -06:00
for _, n := range n.Nodes {
if n == nil {
continue
}
2015-02-14 00:58:41 -06:00
if _, err := EvalRaw(n, ctx); err != nil {
diags = diags.Append(err)
if diags.HasErrors() {
// Halt if we get some errors, but warnings are okay.
break
}
2015-02-14 00:58:41 -06:00
}
2015-02-04 19:23:26 -06:00
}
return nil, diags.ErrWithWarnings()
2015-02-04 19:23:26 -06:00
}
2015-02-11 10:48:45 -06:00
// EvalNodeFilterable impl.
func (n *EvalSequence) Filter(fn EvalNodeFilterFunc) {
for i, node := range n.Nodes {
n.Nodes[i] = fn(node)
}
}