github.com/ns1/terraform@v0.7.10-0.20161109153551-8949419bef40/terraform/node_provider.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/config" 7 ) 8 9 // NodeApplyableProvider represents a provider during an apply. 10 // 11 // NOTE: There is a lot of logic here that will be shared with non-Apply. 12 // The plan is to abstract that eventually into an embedded abstract struct. 13 type NodeApplyableProvider struct { 14 NameValue string 15 PathValue []string 16 Config *config.ProviderConfig 17 } 18 19 func (n *NodeApplyableProvider) Name() string { 20 result := fmt.Sprintf("provider.%s", n.NameValue) 21 if len(n.PathValue) > 1 { 22 result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result) 23 } 24 25 return result 26 } 27 28 // GraphNodeSubPath 29 func (n *NodeApplyableProvider) Path() []string { 30 return n.PathValue 31 } 32 33 // GraphNodeReferencer 34 func (n *NodeApplyableProvider) References() []string { 35 if n.Config == nil { 36 return nil 37 } 38 39 return ReferencesFromConfig(n.Config.RawConfig) 40 } 41 42 // GraphNodeProvider 43 func (n *NodeApplyableProvider) ProviderName() string { 44 return n.NameValue 45 } 46 47 // GraphNodeProvider 48 func (n *NodeApplyableProvider) ProviderConfig() *config.RawConfig { 49 if n.Config == nil { 50 return nil 51 } 52 53 return n.Config.RawConfig 54 } 55 56 // GraphNodeAttachProvider 57 func (n *NodeApplyableProvider) AttachProvider(c *config.ProviderConfig) { 58 n.Config = c 59 } 60 61 // GraphNodeEvalable 62 func (n *NodeApplyableProvider) EvalTree() EvalNode { 63 return ProviderEvalTree(n.NameValue, n.ProviderConfig()) 64 }