mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
d1b40de242
The provider config was not being properly merged across module boundaries during the Input walk over the graph, so when a provider was configured at the top level, resources in modules could improperly trigger a request for input for a provider attribute that's already defined.
75 lines
1.5 KiB
Go
75 lines
1.5 KiB
Go
package terraform
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/config"
|
|
)
|
|
|
|
// ProviderEvalTree returns the evaluation tree for initializing and
|
|
// configuring providers.
|
|
func ProviderEvalTree(n string, config *config.RawConfig) EvalNode {
|
|
var provider ResourceProvider
|
|
var resourceConfig *ResourceConfig
|
|
|
|
seq := make([]EvalNode, 0, 5)
|
|
seq = append(seq, &EvalInitProvider{Name: n})
|
|
|
|
// Input stuff
|
|
seq = append(seq, &EvalOpFilter{
|
|
Ops: []walkOperation{walkInput},
|
|
Node: &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalGetProvider{
|
|
Name: n,
|
|
Output: &provider,
|
|
},
|
|
&EvalInterpolate{
|
|
Config: config,
|
|
Output: &resourceConfig,
|
|
},
|
|
&EvalBuildProviderConfig{
|
|
Provider: n,
|
|
Config: &resourceConfig,
|
|
Output: &resourceConfig,
|
|
},
|
|
&EvalInputProvider{
|
|
Name: n,
|
|
Provider: &provider,
|
|
Config: &resourceConfig,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
// Apply stuff
|
|
seq = append(seq, &EvalOpFilter{
|
|
Ops: []walkOperation{walkValidate, walkRefresh, walkPlan, walkApply},
|
|
Node: &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalGetProvider{
|
|
Name: n,
|
|
Output: &provider,
|
|
},
|
|
&EvalInterpolate{
|
|
Config: config,
|
|
Output: &resourceConfig,
|
|
},
|
|
&EvalBuildProviderConfig{
|
|
Provider: n,
|
|
Config: &resourceConfig,
|
|
Output: &resourceConfig,
|
|
},
|
|
&EvalValidateProvider{
|
|
Provider: &provider,
|
|
Config: &resourceConfig,
|
|
},
|
|
&EvalConfigProvider{
|
|
Provider: n,
|
|
Config: &resourceConfig,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
return &EvalSequence{Nodes: seq}
|
|
}
|