package terraform
import (
- "fmt"
+ "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 (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)
- }
+var (
+ _ GraphNodeSubPath = (*NodeAbstractProvider)(nil)
+ _ RemovableIfNotTargeted = (*NodeAbstractProvider)(nil)
+ _ GraphNodeReferencer = (*NodeAbstractProvider)(nil)
+ _ GraphNodeProvider = (*NodeAbstractProvider)(nil)
+ _ GraphNodeAttachProvider = (*NodeAbstractProvider)(nil)
+ _ GraphNodeAttachProviderConfigSchema = (*NodeAbstractProvider)(nil)
+ _ dag.GraphNodeDotter = (*NodeAbstractProvider)(nil)
+)
- return result
+func (n *NodeAbstractProvider) Name() string {
+ 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.RawConfig {
+func (n *NodeAbstractProvider) ProviderConfig() *configs.Provider {
if n.Config == nil {
return nil
}
- return n.Config.RawConfig
+ return n.Config
}
// 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{