mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
e4ef1fe553
This adds the proper logic for "disabling" providers to the new apply graph: interolating and storing the config for inheritance but not actually initializing and configuring the provider. This is important since parent modules will often contain incomplete provider configurations for the purpose of inheritance that would error if they were actually attempted to be configured (since they're incomplete). If the provider is not used, it should be "disabled".
39 lines
869 B
Go
39 lines
869 B
Go
package terraform
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// NodeDisabledProvider represents a provider that is disabled. A disabled
|
|
// provider does nothing. It exists to properly set inheritance information
|
|
// for child providers.
|
|
type NodeDisabledProvider struct {
|
|
*NodeAbstractProvider
|
|
}
|
|
|
|
func (n *NodeDisabledProvider) Name() string {
|
|
return fmt.Sprintf("%s (disabled)", n.NodeAbstractProvider.Name())
|
|
}
|
|
|
|
// GraphNodeEvalable
|
|
func (n *NodeDisabledProvider) EvalTree() EvalNode {
|
|
var resourceConfig *ResourceConfig
|
|
return &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalInterpolate{
|
|
Config: n.ProviderConfig(),
|
|
Output: &resourceConfig,
|
|
},
|
|
&EvalBuildProviderConfig{
|
|
Provider: n.ProviderName(),
|
|
Config: &resourceConfig,
|
|
Output: &resourceConfig,
|
|
},
|
|
&EvalSetProviderConfig{
|
|
Provider: n.ProviderName(),
|
|
Config: &resourceConfig,
|
|
},
|
|
},
|
|
}
|
|
}
|