]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/terraform/terraform/node_provider_abstract.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / node_provider_abstract.go
1 package terraform
2
3 import (
4 "github.com/hashicorp/terraform/addrs"
5 "github.com/hashicorp/terraform/configs"
6 "github.com/hashicorp/terraform/configs/configschema"
7
8 "github.com/hashicorp/terraform/dag"
9 )
10
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
14
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 {
18 Addr addrs.AbsProviderConfig
19
20 // The fields below will be automatically set using the Attach
21 // interfaces if you're running those transforms, but also be explicitly
22 // set if you already have that information.
23
24 Config *configs.Provider
25 Schema *configschema.Block
26 }
27
28 var (
29 _ GraphNodeSubPath = (*NodeAbstractProvider)(nil)
30 _ RemovableIfNotTargeted = (*NodeAbstractProvider)(nil)
31 _ GraphNodeReferencer = (*NodeAbstractProvider)(nil)
32 _ GraphNodeProvider = (*NodeAbstractProvider)(nil)
33 _ GraphNodeAttachProvider = (*NodeAbstractProvider)(nil)
34 _ GraphNodeAttachProviderConfigSchema = (*NodeAbstractProvider)(nil)
35 _ dag.GraphNodeDotter = (*NodeAbstractProvider)(nil)
36 )
37
38 func (n *NodeAbstractProvider) Name() string {
39 return n.Addr.String()
40 }
41
42 // GraphNodeSubPath
43 func (n *NodeAbstractProvider) Path() addrs.ModuleInstance {
44 return n.Addr.Module
45 }
46
47 // RemovableIfNotTargeted
48 func (n *NodeAbstractProvider) RemoveIfNotTargeted() bool {
49 // We need to add this so that this node will be removed if
50 // it isn't targeted or a dependency of a target.
51 return true
52 }
53
54 // GraphNodeReferencer
55 func (n *NodeAbstractProvider) References() []*addrs.Reference {
56 if n.Config == nil || n.Schema == nil {
57 return nil
58 }
59
60 return ReferencesFromConfig(n.Config.Config, n.Schema)
61 }
62
63 // GraphNodeProvider
64 func (n *NodeAbstractProvider) ProviderAddr() addrs.AbsProviderConfig {
65 return n.Addr
66 }
67
68 // GraphNodeProvider
69 func (n *NodeAbstractProvider) ProviderConfig() *configs.Provider {
70 if n.Config == nil {
71 return nil
72 }
73
74 return n.Config
75 }
76
77 // GraphNodeAttachProvider
78 func (n *NodeAbstractProvider) AttachProvider(c *configs.Provider) {
79 n.Config = c
80 }
81
82 // GraphNodeAttachProviderConfigSchema impl.
83 func (n *NodeAbstractProvider) AttachProviderConfigSchema(schema *configschema.Block) {
84 n.Schema = schema
85 }
86
87 // GraphNodeDotter impl.
88 func (n *NodeAbstractProvider) DotNode(name string, opts *dag.DotOpts) *dag.DotNode {
89 return &dag.DotNode{
90 Name: name,
91 Attrs: map[string]string{
92 "label": n.Name(),
93 "shape": "diamond",
94 },
95 }
96 }