forked from CiscoDevNet/terraform-provider-mso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval_sequence.go
42 lines (35 loc) · 908 Bytes
/
eval_sequence.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package terraform
import (
"github.com/hashicorp/terraform-plugin-sdk/internal/tfdiags"
)
// EvalSequence is an EvalNode that evaluates in sequence.
type EvalSequence struct {
Nodes []EvalNode
}
func (n *EvalSequence) Eval(ctx EvalContext) (interface{}, error) {
var diags tfdiags.Diagnostics
for _, n := range n.Nodes {
if n == nil {
continue
}
if _, err := EvalRaw(n, ctx); err != nil {
if _, isEarlyExit := err.(EvalEarlyExitError); isEarlyExit {
// In this path we abort early, losing any non-error
// diagnostics we saw earlier.
return nil, err
}
diags = diags.Append(err)
if diags.HasErrors() {
// Halt if we get some errors, but warnings are okay.
break
}
}
}
return nil, diags.ErrWithWarnings()
}
// EvalNodeFilterable impl.
func (n *EvalSequence) Filter(fn EvalNodeFilterFunc) {
for i, node := range n.Nodes {
n.Nodes[i] = fn(node)
}
}