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".
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package terraform
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/config"
|
|
)
|
|
|
|
// NodeAbstractProvider represents a provider that has no associated operations.
|
|
// It registers all the common interfaces across operations for providers.
|
|
type NodeAbstractProvider struct {
|
|
NameValue string
|
|
PathValue []string
|
|
|
|
// The fields below will be automatically set using the Attach
|
|
// interfaces if you're running those transforms, but also be explicitly
|
|
// set if you already have that information.
|
|
|
|
Config *config.ProviderConfig
|
|
}
|
|
|
|
func (n *NodeAbstractProvider) Name() string {
|
|
result := fmt.Sprintf("provider.%s", n.NameValue)
|
|
if len(n.PathValue) > 1 {
|
|
result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result)
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
// GraphNodeSubPath
|
|
func (n *NodeAbstractProvider) Path() []string {
|
|
return n.PathValue
|
|
}
|
|
|
|
// GraphNodeReferencer
|
|
func (n *NodeAbstractProvider) References() []string {
|
|
if n.Config == nil {
|
|
return nil
|
|
}
|
|
|
|
return ReferencesFromConfig(n.Config.RawConfig)
|
|
}
|
|
|
|
// GraphNodeProvider
|
|
func (n *NodeAbstractProvider) ProviderName() string {
|
|
return n.NameValue
|
|
}
|
|
|
|
// GraphNodeProvider
|
|
func (n *NodeAbstractProvider) ProviderConfig() *config.RawConfig {
|
|
if n.Config == nil {
|
|
return nil
|
|
}
|
|
|
|
return n.Config.RawConfig
|
|
}
|
|
|
|
// GraphNodeAttachProvider
|
|
func (n *NodeAbstractProvider) AttachProvider(c *config.ProviderConfig) {
|
|
n.Config = c
|
|
}
|