package terraform
import (
- "fmt"
- "strings"
+ "github.com/hashicorp/terraform/addrs"
+ "github.com/hashicorp/terraform/configs"
+ "github.com/hashicorp/terraform/configs/configschema"
- "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/dag"
)
// 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
+ Addr addrs.AbsProviderConfig
// 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
+ Config *configs.Provider
+ Schema *configschema.Block
}
-func ResolveProviderName(name string, path []string) string {
- if strings.Contains(name, "provider.") {
- // already resolved
- return name
- }
-
- name = fmt.Sprintf("provider.%s", name)
- if len(path) >= 1 {
- name = fmt.Sprintf("%s.%s", modulePrefixStr(path), name)
- }
-
- return name
-}
+var (
+ _ GraphNodeSubPath = (*NodeAbstractProvider)(nil)
+ _ RemovableIfNotTargeted = (*NodeAbstractProvider)(nil)
+ _ GraphNodeReferencer = (*NodeAbstractProvider)(nil)
+ _ GraphNodeProvider = (*NodeAbstractProvider)(nil)
+ _ GraphNodeAttachProvider = (*NodeAbstractProvider)(nil)
+ _ GraphNodeAttachProviderConfigSchema = (*NodeAbstractProvider)(nil)
+ _ dag.GraphNodeDotter = (*NodeAbstractProvider)(nil)
+)
func (n *NodeAbstractProvider) Name() string {
- return ResolveProviderName(n.NameValue, n.PathValue)
+ return n.Addr.String()
}
// GraphNodeSubPath
-func (n *NodeAbstractProvider) Path() []string {
- return n.PathValue
+func (n *NodeAbstractProvider) Path() addrs.ModuleInstance {
+ return n.Addr.Module
}
// RemovableIfNotTargeted
}
// GraphNodeReferencer
-func (n *NodeAbstractProvider) References() []string {
- if n.Config == nil {
+func (n *NodeAbstractProvider) References() []*addrs.Reference {
+ if n.Config == nil || n.Schema == nil {
return nil
}
- return ReferencesFromConfig(n.Config.RawConfig)
+ return ReferencesFromConfig(n.Config.Config, n.Schema)
}
// GraphNodeProvider
-func (n *NodeAbstractProvider) ProviderName() string {
- return n.NameValue
+func (n *NodeAbstractProvider) ProviderAddr() addrs.AbsProviderConfig {
+ return n.Addr
}
// GraphNodeProvider
-func (n *NodeAbstractProvider) ProviderConfig() *config.ProviderConfig {
+func (n *NodeAbstractProvider) ProviderConfig() *configs.Provider {
if n.Config == nil {
return nil
}
}
// GraphNodeAttachProvider
-func (n *NodeAbstractProvider) AttachProvider(c *config.ProviderConfig) {
+func (n *NodeAbstractProvider) AttachProvider(c *configs.Provider) {
n.Config = c
}
+// GraphNodeAttachProviderConfigSchema impl.
+func (n *NodeAbstractProvider) AttachProviderConfigSchema(schema *configschema.Block) {
+ n.Schema = schema
+}
+
// GraphNodeDotter impl.
func (n *NodeAbstractProvider) DotNode(name string, opts *dag.DotOpts) *dag.DotNode {
return &dag.DotNode{