github.com/mehmetalisavas/terraform@v0.7.10/terraform/node_provider_abstract.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/config" 7 ) 8 9 // NodeAbstractProvider represents a provider that has no associated operations. 10 // It registers all the common interfaces across operations for providers. 11 type NodeAbstractProvider struct { 12 NameValue string 13 PathValue []string 14 15 // The fields below will be automatically set using the Attach 16 // interfaces if you're running those transforms, but also be explicitly 17 // set if you already have that information. 18 19 Config *config.ProviderConfig 20 } 21 22 func (n *NodeAbstractProvider) Name() string { 23 result := fmt.Sprintf("provider.%s", n.NameValue) 24 if len(n.PathValue) > 1 { 25 result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result) 26 } 27 28 return result 29 } 30 31 // GraphNodeSubPath 32 func (n *NodeAbstractProvider) Path() []string { 33 return n.PathValue 34 } 35 36 // GraphNodeReferencer 37 func (n *NodeAbstractProvider) References() []string { 38 if n.Config == nil { 39 return nil 40 } 41 42 return ReferencesFromConfig(n.Config.RawConfig) 43 } 44 45 // GraphNodeProvider 46 func (n *NodeAbstractProvider) ProviderName() string { 47 return n.NameValue 48 } 49 50 // GraphNodeProvider 51 func (n *NodeAbstractProvider) ProviderConfig() *config.RawConfig { 52 if n.Config == nil { 53 return nil 54 } 55 56 return n.Config.RawConfig 57 } 58 59 // GraphNodeAttachProvider 60 func (n *NodeAbstractProvider) AttachProvider(c *config.ProviderConfig) { 61 n.Config = c 62 }