mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
7b510c4add
* terraform: refactor signature of EvalContext.InitProvisioner Nothing was using the returned provisioners.Interface, so I simplified the signature. * terraform: remove provisioner-related EvalTree()s The various Evals in eval_provisioner were removed from all callers and replaced with straight-through code. `NodeValidatableResource.EvalTree()` to `Execute()` was more involved. I chose to leave the `EvalValidateResource` and `EvalValidateProvisioner` Eval functions mostly as-is, changing the main function to `.Validate` to make it clear that these are no longer eval nodes. Eventually I expect to rename the file (perhaps to just Validate).
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package terraform
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/addrs"
|
|
)
|
|
|
|
// NodeProvisioner represents a provider that has no associated operations.
|
|
// It registers all the common interfaces across operations for providers.
|
|
type NodeProvisioner struct {
|
|
NameValue string
|
|
PathValue addrs.ModuleInstance
|
|
}
|
|
|
|
var (
|
|
_ GraphNodeModuleInstance = (*NodeProvisioner)(nil)
|
|
_ GraphNodeProvisioner = (*NodeProvisioner)(nil)
|
|
_ GraphNodeExecutable = (*NodeProvisioner)(nil)
|
|
)
|
|
|
|
func (n *NodeProvisioner) Name() string {
|
|
result := fmt.Sprintf("provisioner.%s", n.NameValue)
|
|
if len(n.PathValue) > 0 {
|
|
result = fmt.Sprintf("%s.%s", n.PathValue.String(), result)
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
// GraphNodeModuleInstance
|
|
func (n *NodeProvisioner) Path() addrs.ModuleInstance {
|
|
return n.PathValue
|
|
}
|
|
|
|
// GraphNodeProvisioner
|
|
func (n *NodeProvisioner) ProvisionerName() string {
|
|
return n.NameValue
|
|
}
|
|
|
|
// GraphNodeExecutable impl.
|
|
func (n *NodeProvisioner) Execute(ctx EvalContext, op walkOperation) error {
|
|
return ctx.InitProvisioner(n.NameValue)
|
|
}
|