1package terraform 2 3import ( 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. 11type 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. 23type NullGraphWalker struct{} 24 25func (NullGraphWalker) EnterPath(addrs.ModuleInstance) EvalContext { return new(MockEvalContext) } 26func (NullGraphWalker) ExitPath(addrs.ModuleInstance) {} 27func (NullGraphWalker) EnterVertex(dag.Vertex) {} 28func (NullGraphWalker) ExitVertex(dag.Vertex, tfdiags.Diagnostics) {} 29func (NullGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode { return n } 30func (NullGraphWalker) ExitEvalTree(dag.Vertex, interface{}, error) tfdiags.Diagnostics { 31 return nil 32} 33