2015-02-04 19:23:26 -06:00
|
|
|
package terraform
|
|
|
|
|
2018-05-29 13:47:49 -05:00
|
|
|
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) {
|
2018-05-29 13:47:49 -05:00
|
|
|
var diags tfdiags.Diagnostics
|
|
|
|
|
2015-02-14 00:58:41 -06:00
|
|
|
for _, n := range n.Nodes {
|
2017-01-27 23:15:43 -06:00
|
|
|
if n == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:58:41 -06:00
|
|
|
if _, err := EvalRaw(n, ctx); err != nil {
|
2018-05-29 13:47:49 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-05-29 13:47:49 -05: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)
|
|
|
|
}
|
|
|
|
}
|