rename attachDataResourceDependsOnTransformer

Clarify the use of this transformer, interface and method which now does
not apply to anything but `depends_on` for data sources,
This commit is contained in:
James Bardin 2021-03-08 13:46:28 -05:00
parent 3d8b43dfe7
commit 3c6b2a8780
4 changed files with 27 additions and 27 deletions

View File

@ -84,7 +84,7 @@ func (b *ImportGraphBuilder) Steps() []GraphTransformer {
// Make sure data sources are aware of any depends_on from the // Make sure data sources are aware of any depends_on from the
// configuration // configuration
&attachDataResourceDependenciesTransformer{}, &attachDataResourceDependsOnTransformer{},
// Close opened plugin connections // Close opened plugin connections
&CloseProviderTransformer{}, &CloseProviderTransformer{},

View File

@ -137,7 +137,7 @@ func (b *PlanGraphBuilder) Steps() []GraphTransformer {
// Make sure data sources are aware of any depends_on from the // Make sure data sources are aware of any depends_on from the
// configuration // configuration
&attachDataResourceDependenciesTransformer{}, &attachDataResourceDependsOnTransformer{},
// Target // Target
&TargetsTransformer{Targets: b.Targets}, &TargetsTransformer{Targets: b.Targets},

View File

@ -62,7 +62,7 @@ type NodeAbstractResource struct {
// Set from GraphNodeTargetable // Set from GraphNodeTargetable
Targets []addrs.Targetable Targets []addrs.Targetable
// Set from AttachResourceDependencies // Set from AttachDataResourceDependsOn
dependsOn []addrs.ConfigResource dependsOn []addrs.ConfigResource
forceDependsOn bool forceDependsOn bool
@ -71,18 +71,18 @@ type NodeAbstractResource struct {
} }
var ( var (
_ GraphNodeReferenceable = (*NodeAbstractResource)(nil) _ GraphNodeReferenceable = (*NodeAbstractResource)(nil)
_ GraphNodeReferencer = (*NodeAbstractResource)(nil) _ GraphNodeReferencer = (*NodeAbstractResource)(nil)
_ GraphNodeProviderConsumer = (*NodeAbstractResource)(nil) _ GraphNodeProviderConsumer = (*NodeAbstractResource)(nil)
_ GraphNodeProvisionerConsumer = (*NodeAbstractResource)(nil) _ GraphNodeProvisionerConsumer = (*NodeAbstractResource)(nil)
_ GraphNodeConfigResource = (*NodeAbstractResource)(nil) _ GraphNodeConfigResource = (*NodeAbstractResource)(nil)
_ GraphNodeAttachResourceConfig = (*NodeAbstractResource)(nil) _ GraphNodeAttachResourceConfig = (*NodeAbstractResource)(nil)
_ GraphNodeAttachResourceSchema = (*NodeAbstractResource)(nil) _ GraphNodeAttachResourceSchema = (*NodeAbstractResource)(nil)
_ GraphNodeAttachProvisionerSchema = (*NodeAbstractResource)(nil) _ GraphNodeAttachProvisionerSchema = (*NodeAbstractResource)(nil)
_ GraphNodeAttachProviderMetaConfigs = (*NodeAbstractResource)(nil) _ GraphNodeAttachProviderMetaConfigs = (*NodeAbstractResource)(nil)
_ GraphNodeTargetable = (*NodeAbstractResource)(nil) _ GraphNodeTargetable = (*NodeAbstractResource)(nil)
_ graphNodeAttachResourceDependencies = (*NodeAbstractResource)(nil) _ graphNodeAttachDataResourceDependsOn = (*NodeAbstractResource)(nil)
_ dag.GraphNodeDotter = (*NodeAbstractResource)(nil) _ dag.GraphNodeDotter = (*NodeAbstractResource)(nil)
) )
// NewNodeAbstractResource creates an abstract resource graph node for // NewNodeAbstractResource creates an abstract resource graph node for
@ -264,8 +264,8 @@ func (n *NodeAbstractResource) SetTargets(targets []addrs.Targetable) {
n.Targets = targets n.Targets = targets
} }
// graphNodeAttachResourceDependencies // graphNodeAttachDataResourceDependsOn
func (n *NodeAbstractResource) AttachResourceDependencies(deps []addrs.ConfigResource, force bool) { func (n *NodeAbstractResource) AttachDataResourceDependsOn(deps []addrs.ConfigResource, force bool) {
n.dependsOn = deps n.dependsOn = deps
n.forceDependsOn = force n.forceDependsOn = force
} }

View File

@ -50,7 +50,7 @@ type graphNodeDependsOn interface {
DependsOn() []*addrs.Reference DependsOn() []*addrs.Reference
} }
// graphNodeAttachResourceDependencies records all resources that are transitively // graphNodeAttachDataResourceDependsOn records all resources that are transitively
// referenced through depends_on in the configuration. This is used by data // referenced through depends_on in the configuration. This is used by data
// resources to determine if they can be read during the plan, or if they need // resources to determine if they can be read during the plan, or if they need
// to be further delayed until apply. // to be further delayed until apply.
@ -60,18 +60,18 @@ type graphNodeDependsOn interface {
// unrelated module instances, the fact that it only happens when there are any // unrelated module instances, the fact that it only happens when there are any
// resource updates pending means we can still avoid the problem of the // resource updates pending means we can still avoid the problem of the
// "perpetual diff" // "perpetual diff"
type graphNodeAttachResourceDependencies interface { type graphNodeAttachDataResourceDependsOn interface {
GraphNodeConfigResource GraphNodeConfigResource
graphNodeDependsOn graphNodeDependsOn
// AttachResourceDependencies stored the discovered dependencies in the // AttachDataResourceDependsOn stores the discovered dependencies in the
// resource node for evaluation later. // resource node for evaluation later.
// //
// The force parameter indicates that even if there are no dependencies, // The force parameter indicates that even if there are no dependencies,
// force the data source to act as though there are for refresh purposes. // force the data source to act as though there are for refresh purposes.
// This is needed because yet-to-be-created resources won't be in the // This is needed because yet-to-be-created resources won't be in the
// initial refresh graph, but may still be referenced through depends_on. // initial refresh graph, but may still be referenced through depends_on.
AttachResourceDependencies(deps []addrs.ConfigResource, force bool) AttachDataResourceDependsOn(deps []addrs.ConfigResource, force bool)
} }
// GraphNodeReferenceOutside is an interface that can optionally be implemented. // GraphNodeReferenceOutside is an interface that can optionally be implemented.
@ -157,12 +157,12 @@ func (m depMap) add(v dag.Vertex) {
} }
} }
// attachDataResourceDependenciesTransformer records all resources transitively referenced // attachDataResourceDependsOnTransformer records all resources transitively
// through a configuration depends_on. // referenced through a configuration depends_on.
type attachDataResourceDependenciesTransformer struct { type attachDataResourceDependsOnTransformer struct {
} }
func (t attachDataResourceDependenciesTransformer) Transform(g *Graph) error { func (t attachDataResourceDependsOnTransformer) Transform(g *Graph) error {
// First we need to make a map of referenceable addresses to their vertices. // First we need to make a map of referenceable addresses to their vertices.
// This is very similar to what's done in ReferenceTransformer, but we keep // This is very similar to what's done in ReferenceTransformer, but we keep
// implementation separate as they may need to change independently. // implementation separate as they may need to change independently.
@ -170,7 +170,7 @@ func (t attachDataResourceDependenciesTransformer) Transform(g *Graph) error {
refMap := NewReferenceMap(vertices) refMap := NewReferenceMap(vertices)
for _, v := range vertices { for _, v := range vertices {
depender, ok := v.(graphNodeAttachResourceDependencies) depender, ok := v.(graphNodeAttachDataResourceDependsOn)
if !ok { if !ok {
continue continue
} }
@ -195,7 +195,7 @@ func (t attachDataResourceDependenciesTransformer) Transform(g *Graph) error {
} }
log.Printf("[TRACE] attachDataDependenciesTransformer: %s depends on %s", depender.ResourceAddr(), res) log.Printf("[TRACE] attachDataDependenciesTransformer: %s depends on %s", depender.ResourceAddr(), res)
depender.AttachResourceDependencies(res, fromModule) depender.AttachDataResourceDependsOn(res, fromModule)
} }
return nil return nil