]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/hashicorp/terraform/terraform/node_provider_abstract.go
Merge branch 'fix_read_test' of github.com:alexandreFre/terraform-provider-statuscake
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / node_provider_abstract.go
index 9e490f7b4f04ba0256d2e2bcccbf05a59a64340f..a0cdcfe01d6a0e70dafb51380a80922055288a9c 100644 (file)
@@ -1,10 +1,10 @@
 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"
 )
 
@@ -15,37 +15,33 @@ type ConcreteProviderNodeFunc func(*NodeAbstractProvider) dag.Vertex
 // 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
@@ -56,21 +52,21 @@ func (n *NodeAbstractProvider) RemoveIfNotTargeted() bool {
 }
 
 // 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
        }
@@ -79,10 +75,15 @@ func (n *NodeAbstractProvider) ProviderConfig() *config.ProviderConfig {
 }
 
 // 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{