]>
Commit | Line | Data |
---|---|---|
1 | package terraform | |
2 | ||
3 | import ( | |
4 | "github.com/hashicorp/terraform/addrs" | |
5 | "github.com/hashicorp/terraform/dag" | |
6 | "github.com/hashicorp/terraform/tfdiags" | |
7 | ) | |
8 | ||
9 | // GraphWalker is an interface that can be implemented that when used | |
10 | // with Graph.Walk will invoke the given callbacks under certain events. | |
11 | type GraphWalker interface { | |
12 | EnterPath(addrs.ModuleInstance) EvalContext | |
13 | ExitPath(addrs.ModuleInstance) | |
14 | EnterVertex(dag.Vertex) | |
15 | ExitVertex(dag.Vertex, tfdiags.Diagnostics) | |
16 | EnterEvalTree(dag.Vertex, EvalNode) EvalNode | |
17 | ExitEvalTree(dag.Vertex, interface{}, error) tfdiags.Diagnostics | |
18 | } | |
19 | ||
20 | // NullGraphWalker is a GraphWalker implementation that does nothing. | |
21 | // This can be embedded within other GraphWalker implementations for easily | |
22 | // implementing all the required functions. | |
23 | type NullGraphWalker struct{} | |
24 | ||
25 | func (NullGraphWalker) EnterPath(addrs.ModuleInstance) EvalContext { return new(MockEvalContext) } | |
26 | func (NullGraphWalker) ExitPath(addrs.ModuleInstance) {} | |
27 | func (NullGraphWalker) EnterVertex(dag.Vertex) {} | |
28 | func (NullGraphWalker) ExitVertex(dag.Vertex, tfdiags.Diagnostics) {} | |
29 | func (NullGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode { return n } | |
30 | func (NullGraphWalker) ExitEvalTree(dag.Vertex, interface{}, error) tfdiags.Diagnostics { | |
31 | return nil | |
32 | } |