Skip to content

Commit

Permalink
terraform: refactor Node*Ouput
Browse files Browse the repository at this point in the history
This commit refactors NodeApplyableOutput and NodeDestroyableOutput into
the new Execute() pattern, collapsing the functions in eval_output.go
into one place.

I also reverted a recent decision to have Execute take a _pointer_ to a
walkOperation: I was thinking of interfaces, not constant bytes, so all
it did was cause problems.

And finally I removed eval_lang.go, which was unused.
  • Loading branch information
mildwonkey committed Sep 9, 2020
1 parent e191a57 commit 069f379
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 232 deletions.
61 changes: 0 additions & 61 deletions terraform/eval_lang.go

This file was deleted.

138 changes: 0 additions & 138 deletions terraform/eval_output.go

This file was deleted.

2 changes: 1 addition & 1 deletion terraform/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ package terraform
// the process of being removed. A given graph node should _not_ implement both
// GraphNodeExecutable and GraphNodeEvalable.
type GraphNodeExecutable interface {
Execute(EvalContext, *walkOperation) error
Execute(EvalContext, walkOperation) error
}
2 changes: 1 addition & 1 deletion terraform/graph_walk_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (w *ContextGraphWalker) Execute(ctx EvalContext, n GraphNodeExecutable) tfd
// Acquire a lock on the semaphore
w.Context.parallelSem.Acquire()

err := n.Execute(ctx, &w.Operation)
err := n.Execute(ctx, w.Operation)

// Release the semaphore
w.Context.parallelSem.Release()
Expand Down
2 changes: 1 addition & 1 deletion terraform/node_data_destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
)

// GraphNodeExecutable
func (n *NodeDestroyableDataResourceInstance) Execute(ctx EvalContext, op *walkOperation) error {
func (n *NodeDestroyableDataResourceInstance) Execute(ctx EvalContext, op walkOperation) error {
log.Printf("[TRACE] NodeDestroyableDataResourceInstance: removing state object for %s", n.Addr)
ctx.State().SetResourceInstanceCurrent(n.Addr, nil, n.ResolvedProvider)
return nil
Expand Down
2 changes: 1 addition & 1 deletion terraform/node_data_destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestNodeDataDestroyExecute(t *testing.T) {
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
}}

err := node.Execute(ctx, nil)
err := node.Execute(ctx, walkApply)
if err != nil {
t.Fatalf("unexpected error: %s", err.Error())
}
Expand Down
4 changes: 1 addition & 3 deletions terraform/node_data_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ type NodeRefreshableDataResourceInstance struct {
}

// GraphNodeExecutable
func (n *NodeRefreshableDataResourceInstance) Execute(ctx EvalContext, op *walkOperation) error {
func (n *NodeRefreshableDataResourceInstance) Execute(ctx EvalContext, op walkOperation) error {
addr := n.ResourceInstanceAddr()

// These variables are the state for the eval sequence below, and are
Expand Down Expand Up @@ -280,7 +280,5 @@ func (n *NodeRefreshableDataResourceInstance) Execute(ctx EvalContext, op *walkO
return err
}
}

return err

}
Loading

0 comments on commit 069f379

Please sign in to comment.