7 "github.com/hashicorp/terraform/config"
8 "github.com/hashicorp/terraform/dag"
11 // ConcreteProviderNodeFunc is a callback type used to convert an
12 // abstract provider to a concrete one of some type.
13 type ConcreteProviderNodeFunc func(*NodeAbstractProvider) dag.Vertex
15 // NodeAbstractProvider represents a provider that has no associated operations.
16 // It registers all the common interfaces across operations for providers.
17 type NodeAbstractProvider struct {
21 // The fields below will be automatically set using the Attach
22 // interfaces if you're running those transforms, but also be explicitly
23 // set if you already have that information.
25 Config *config.ProviderConfig
28 func ResolveProviderName(name string, path []string) string {
29 if strings.Contains(name, "provider.") {
34 name = fmt.Sprintf("provider.%s", name)
36 name = fmt.Sprintf("%s.%s", modulePrefixStr(path), name)
42 func (n *NodeAbstractProvider) Name() string {
43 return ResolveProviderName(n.NameValue, n.PathValue)
47 func (n *NodeAbstractProvider) Path() []string {
51 // RemovableIfNotTargeted
52 func (n *NodeAbstractProvider) RemoveIfNotTargeted() bool {
53 // We need to add this so that this node will be removed if
54 // it isn't targeted or a dependency of a target.
58 // GraphNodeReferencer
59 func (n *NodeAbstractProvider) References() []string {
64 return ReferencesFromConfig(n.Config.RawConfig)
68 func (n *NodeAbstractProvider) ProviderName() string {
73 func (n *NodeAbstractProvider) ProviderConfig() *config.ProviderConfig {
81 // GraphNodeAttachProvider
82 func (n *NodeAbstractProvider) AttachProvider(c *config.ProviderConfig) {
86 // GraphNodeDotter impl.
87 func (n *NodeAbstractProvider) DotNode(name string, opts *dag.DotOpts) *dag.DotNode {
90 Attrs: map[string]string{