github.com/opentofu/opentofu@v1.7.1/internal/tofu/graph_walk.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package tofu 7 8 import ( 9 "github.com/opentofu/opentofu/internal/addrs" 10 "github.com/opentofu/opentofu/internal/tfdiags" 11 ) 12 13 // GraphWalker is an interface that can be implemented that when used 14 // with Graph.Walk will invoke the given callbacks under certain events. 15 type GraphWalker interface { 16 EvalContext() EvalContext 17 EnterPath(addrs.ModuleInstance) EvalContext 18 ExitPath(addrs.ModuleInstance) 19 Execute(EvalContext, GraphNodeExecutable) tfdiags.Diagnostics 20 } 21 22 // NullGraphWalker is a GraphWalker implementation that does nothing. 23 // This can be embedded within other GraphWalker implementations for easily 24 // implementing all the required functions. 25 type NullGraphWalker struct{} 26 27 func (NullGraphWalker) EvalContext() EvalContext { return new(MockEvalContext) } 28 func (NullGraphWalker) EnterPath(addrs.ModuleInstance) EvalContext { return new(MockEvalContext) } 29 func (NullGraphWalker) ExitPath(addrs.ModuleInstance) {} 30 func (NullGraphWalker) Execute(EvalContext, GraphNodeExecutable) tfdiags.Diagnostics { return nil }