mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-29 10:21:01 -06:00
16df9c37cf
Chaange ResourceProvider to providers.Interface starting from the context, and fix all type errors. This only replaced some of method calls directly applicable to the providers themselves. The resource methods will follow.
89 lines
2.0 KiB
Go
89 lines
2.0 KiB
Go
package terraform
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/addrs"
|
|
"github.com/hashicorp/terraform/configs"
|
|
"github.com/hashicorp/terraform/providers"
|
|
)
|
|
|
|
// ProviderEvalTree returns the evaluation tree for initializing and
|
|
// configuring providers.
|
|
func ProviderEvalTree(n *NodeApplyableProvider, config *configs.Provider) EvalNode {
|
|
var provider providers.Interface
|
|
|
|
addr := n.Addr
|
|
relAddr := addr.ProviderConfig
|
|
|
|
seq := make([]EvalNode, 0, 5)
|
|
seq = append(seq, &EvalInitProvider{
|
|
TypeName: relAddr.Type,
|
|
Addr: addr.ProviderConfig,
|
|
})
|
|
|
|
// Input stuff
|
|
seq = append(seq, &EvalOpFilter{
|
|
Ops: []walkOperation{walkImport},
|
|
Node: &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalGetProvider{
|
|
Addr: addr,
|
|
Output: &provider,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
seq = append(seq, &EvalOpFilter{
|
|
Ops: []walkOperation{walkValidate},
|
|
Node: &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalGetProvider{
|
|
Addr: addr,
|
|
Output: &provider,
|
|
},
|
|
&EvalValidateProvider{
|
|
Addr: relAddr,
|
|
Provider: &provider,
|
|
Config: config,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
// Apply stuff
|
|
seq = append(seq, &EvalOpFilter{
|
|
Ops: []walkOperation{walkRefresh, walkPlan, walkApply, walkDestroy, walkImport},
|
|
Node: &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalGetProvider{
|
|
Addr: addr,
|
|
Output: &provider,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
// We configure on everything but validate, since validate may
|
|
// not have access to all the variables.
|
|
seq = append(seq, &EvalOpFilter{
|
|
Ops: []walkOperation{walkRefresh, walkPlan, walkApply, walkDestroy, walkImport},
|
|
Node: &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalConfigProvider{
|
|
Addr: relAddr,
|
|
Provider: &provider,
|
|
Config: config,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
return &EvalSequence{Nodes: seq}
|
|
}
|
|
|
|
// CloseProviderEvalTree returns the evaluation tree for closing
|
|
// provider connections that aren't needed anymore.
|
|
func CloseProviderEvalTree(addr addrs.AbsProviderConfig) EvalNode {
|
|
return &EvalCloseProvider{Addr: addr.ProviderConfig}
|
|
}
|