Merge pull request #24930 from hashicorp/jbardin/rename-expanders
Rename expanders
This commit is contained in:
commit
2b9cb0e0e1
|
@ -757,20 +757,20 @@ const testApplyGraphBuilderStr = `
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
module.child (close)
|
module.child (close)
|
||||||
test_object.other
|
test_object.other
|
||||||
module.child
|
|
||||||
module.child (close)
|
module.child (close)
|
||||||
module.child.test_object.other
|
module.child.test_object.other
|
||||||
|
module.child (expand)
|
||||||
module.child.test_object.create
|
module.child.test_object.create
|
||||||
module.child.test_object.create (prepare state)
|
module.child.test_object.create (expand)
|
||||||
module.child.test_object.create (prepare state)
|
module.child.test_object.create (expand)
|
||||||
module.child
|
module.child (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
provisioner.test
|
provisioner.test
|
||||||
module.child.test_object.other
|
module.child.test_object.other
|
||||||
module.child.test_object.create
|
module.child.test_object.create
|
||||||
module.child.test_object.other (prepare state)
|
module.child.test_object.other (expand)
|
||||||
module.child.test_object.other (prepare state)
|
module.child.test_object.other (expand)
|
||||||
module.child
|
module.child (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close)
|
provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
|
@ -784,13 +784,13 @@ root
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close)
|
provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
provisioner.test (close)
|
provisioner.test (close)
|
||||||
test_object.create
|
test_object.create
|
||||||
test_object.create (prepare state)
|
test_object.create (expand)
|
||||||
test_object.create (prepare state)
|
test_object.create (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_object.other
|
test_object.other
|
||||||
test_object.create
|
test_object.create
|
||||||
test_object.other (prepare state)
|
test_object.other (expand)
|
||||||
test_object.other (prepare state)
|
test_object.other (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -803,14 +803,14 @@ provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
root
|
root
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close)
|
provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
test_object.A (prepare state)
|
test_object.A (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_object.A[1] (destroy)
|
test_object.A[1] (destroy)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_object.B
|
test_object.B
|
||||||
test_object.A (prepare state)
|
test_object.A (expand)
|
||||||
test_object.A[1] (destroy)
|
test_object.A[1] (destroy)
|
||||||
test_object.B (prepare state)
|
test_object.B (expand)
|
||||||
test_object.B (prepare state)
|
test_object.B (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
`
|
`
|
||||||
|
|
|
@ -126,26 +126,26 @@ func TestPlanGraphBuilder_dynamicBlock(t *testing.T) {
|
||||||
expected := strings.TrimSpace(`
|
expected := strings.TrimSpace(`
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
test_thing.b
|
test_thing.b (expand)
|
||||||
test_thing.c
|
test_thing.c (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close)
|
provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
test_thing.b
|
test_thing.b (expand)
|
||||||
test_thing.c
|
test_thing.c (expand)
|
||||||
root
|
root
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close)
|
provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.b
|
test_thing.b (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.c
|
test_thing.c (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
test_thing.b
|
test_thing.b (expand)
|
||||||
`)
|
`)
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual)
|
t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual)
|
||||||
|
@ -205,21 +205,21 @@ func TestPlanGraphBuilder_attrAsBlocks(t *testing.T) {
|
||||||
expected := strings.TrimSpace(`
|
expected := strings.TrimSpace(`
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
test_thing.b
|
test_thing.b (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close)
|
provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
test_thing.b
|
test_thing.b (expand)
|
||||||
root
|
root
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close)
|
provider["registry.terraform.io/hashicorp/test"] (close)
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.b
|
test_thing.b (expand)
|
||||||
provider["registry.terraform.io/hashicorp/test"]
|
provider["registry.terraform.io/hashicorp/test"]
|
||||||
test_thing.a
|
test_thing.a (expand)
|
||||||
`)
|
`)
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual)
|
t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual)
|
||||||
|
@ -293,41 +293,41 @@ func TestPlanGraphBuilder_forEach(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testPlanGraphBuilderStr = `
|
const testPlanGraphBuilderStr = `
|
||||||
aws_instance.web
|
aws_instance.web (expand)
|
||||||
aws_security_group.firewall
|
aws_security_group.firewall (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
var.foo
|
var.foo
|
||||||
aws_load_balancer.weblb
|
aws_load_balancer.weblb (expand)
|
||||||
aws_instance.web
|
aws_instance.web (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
aws_security_group.firewall
|
aws_security_group.firewall (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
local.instance_id
|
local.instance_id (expand)
|
||||||
aws_instance.web
|
aws_instance.web (expand)
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
aws_instance.web
|
aws_instance.web (expand)
|
||||||
aws_load_balancer.weblb
|
aws_load_balancer.weblb (expand)
|
||||||
aws_security_group.firewall
|
aws_security_group.firewall (expand)
|
||||||
local.instance_id
|
local.instance_id (expand)
|
||||||
openstack_floating_ip.random
|
openstack_floating_ip.random (expand)
|
||||||
output.instance_id
|
output.instance_id (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
provider["registry.terraform.io/hashicorp/openstack"]
|
provider["registry.terraform.io/hashicorp/openstack"]
|
||||||
var.foo
|
var.foo
|
||||||
openstack_floating_ip.random
|
openstack_floating_ip.random (expand)
|
||||||
provider["registry.terraform.io/hashicorp/openstack"]
|
provider["registry.terraform.io/hashicorp/openstack"]
|
||||||
output.instance_id
|
output.instance_id (expand)
|
||||||
local.instance_id
|
local.instance_id (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
openstack_floating_ip.random
|
openstack_floating_ip.random (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"] (close)
|
provider["registry.terraform.io/hashicorp/aws"] (close)
|
||||||
aws_instance.web
|
aws_instance.web (expand)
|
||||||
aws_load_balancer.weblb
|
aws_load_balancer.weblb (expand)
|
||||||
aws_security_group.firewall
|
aws_security_group.firewall (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
provider["registry.terraform.io/hashicorp/openstack"]
|
provider["registry.terraform.io/hashicorp/openstack"]
|
||||||
provider["registry.terraform.io/hashicorp/openstack"] (close)
|
provider["registry.terraform.io/hashicorp/openstack"] (close)
|
||||||
openstack_floating_ip.random
|
openstack_floating_ip.random (expand)
|
||||||
provider["registry.terraform.io/hashicorp/openstack"]
|
provider["registry.terraform.io/hashicorp/openstack"]
|
||||||
root
|
root
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
|
@ -336,35 +336,35 @@ root
|
||||||
var.foo
|
var.foo
|
||||||
`
|
`
|
||||||
const testPlanGraphBuilderForEachStr = `
|
const testPlanGraphBuilderForEachStr = `
|
||||||
aws_instance.bar
|
aws_instance.bar (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
aws_instance.bar2
|
aws_instance.bar2 (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
aws_instance.bat
|
aws_instance.bat (expand)
|
||||||
aws_instance.boo
|
aws_instance.boo (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
aws_instance.baz
|
aws_instance.baz (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
aws_instance.boo
|
aws_instance.boo (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
aws_instance.foo
|
aws_instance.foo (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
aws_instance.bar
|
aws_instance.bar (expand)
|
||||||
aws_instance.bar2
|
aws_instance.bar2 (expand)
|
||||||
aws_instance.bat
|
aws_instance.bat (expand)
|
||||||
aws_instance.baz
|
aws_instance.baz (expand)
|
||||||
aws_instance.boo
|
aws_instance.boo (expand)
|
||||||
aws_instance.foo
|
aws_instance.foo (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
provider["registry.terraform.io/hashicorp/aws"] (close)
|
provider["registry.terraform.io/hashicorp/aws"] (close)
|
||||||
aws_instance.bar
|
aws_instance.bar (expand)
|
||||||
aws_instance.bar2
|
aws_instance.bar2 (expand)
|
||||||
aws_instance.bat
|
aws_instance.bat (expand)
|
||||||
aws_instance.baz
|
aws_instance.baz (expand)
|
||||||
aws_instance.boo
|
aws_instance.boo (expand)
|
||||||
aws_instance.foo
|
aws_instance.foo (expand)
|
||||||
provider["registry.terraform.io/hashicorp/aws"]
|
provider["registry.terraform.io/hashicorp/aws"]
|
||||||
root
|
root
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
|
|
|
@ -58,13 +58,13 @@ provider["registry.terraform.io/hashicorp/test"] (close) - *terraform.graphNodeC
|
||||||
data.test_object.foo[1] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
data.test_object.foo[1] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
||||||
data.test_object.foo[2] - *terraform.NodeRefreshableManagedResourceInstance
|
data.test_object.foo[2] - *terraform.NodeRefreshableManagedResourceInstance
|
||||||
data.test_object.foo[2] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
data.test_object.foo[2] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
||||||
test_object.foo - *terraform.nodeExpandRefreshableManagedResource
|
test_object.foo (expand) - *terraform.nodeExpandRefreshableManagedResource
|
||||||
test_object.foo[0] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
test_object.foo[0] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
||||||
test_object.foo[1] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
test_object.foo[1] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
||||||
test_object.foo[2] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
test_object.foo[2] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
||||||
root - *terraform.nodeCloseModule
|
root - *terraform.nodeCloseModule
|
||||||
provider["registry.terraform.io/hashicorp/test"] (close) - *terraform.graphNodeCloseProvider
|
provider["registry.terraform.io/hashicorp/test"] (close) - *terraform.graphNodeCloseProvider
|
||||||
test_object.foo - *terraform.nodeExpandRefreshableManagedResource
|
test_object.foo (expand) - *terraform.nodeExpandRefreshableManagedResource
|
||||||
provider["registry.terraform.io/hashicorp/test"] - *terraform.NodeApplyableProvider
|
provider["registry.terraform.io/hashicorp/test"] - *terraform.NodeApplyableProvider
|
||||||
test_object.foo[0] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
test_object.foo[0] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
|
||||||
provider["registry.terraform.io/hashicorp/test"] - *terraform.NodeApplyableProvider
|
provider["registry.terraform.io/hashicorp/test"] - *terraform.NodeApplyableProvider
|
||||||
|
|
|
@ -22,6 +22,10 @@ var (
|
||||||
_ GraphNodeAttachResourceConfig = (*nodeExpandRefreshableDataResource)(nil)
|
_ GraphNodeAttachResourceConfig = (*nodeExpandRefreshableDataResource)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (n *nodeExpandRefreshableDataResource) Name() string {
|
||||||
|
return n.NodeAbstractResource.Name() + " (expand)"
|
||||||
|
}
|
||||||
|
|
||||||
func (n *nodeExpandRefreshableDataResource) References() []*addrs.Reference {
|
func (n *nodeExpandRefreshableDataResource) References() []*addrs.Reference {
|
||||||
return (&NodeRefreshableManagedResource{NodeAbstractResource: n.NodeAbstractResource}).References()
|
return (&NodeRefreshableManagedResource{NodeAbstractResource: n.NodeAbstractResource}).References()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,30 +9,31 @@ import (
|
||||||
"github.com/hashicorp/terraform/lang"
|
"github.com/hashicorp/terraform/lang"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodePlannableLocal represents a named local value in a configuration module,
|
// nodeExpandLocal represents a named local value in a configuration module,
|
||||||
// which has not yet been expanded.
|
// which has not yet been expanded.
|
||||||
type NodePlannableLocal struct {
|
type nodeExpandLocal struct {
|
||||||
Addr addrs.LocalValue
|
Addr addrs.LocalValue
|
||||||
Module addrs.Module
|
Module addrs.Module
|
||||||
Config *configs.Local
|
Config *configs.Local
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ RemovableIfNotTargeted = (*NodePlannableLocal)(nil)
|
_ RemovableIfNotTargeted = (*nodeExpandLocal)(nil)
|
||||||
_ GraphNodeReferenceable = (*NodePlannableLocal)(nil)
|
_ GraphNodeReferenceable = (*nodeExpandLocal)(nil)
|
||||||
_ GraphNodeReferencer = (*NodePlannableLocal)(nil)
|
_ GraphNodeReferencer = (*nodeExpandLocal)(nil)
|
||||||
_ GraphNodeDynamicExpandable = (*NodePlannableLocal)(nil)
|
_ GraphNodeDynamicExpandable = (*nodeExpandLocal)(nil)
|
||||||
_ graphNodeTemporaryValue = (*NodePlannableLocal)(nil)
|
_ graphNodeTemporaryValue = (*nodeExpandLocal)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
// graphNodeTemporaryValue
|
// graphNodeTemporaryValue
|
||||||
func (n *NodePlannableLocal) temporaryValue() bool {
|
func (n *nodeExpandLocal) temporaryValue() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodePlannableLocal) Name() string {
|
func (n *nodeExpandLocal) Name() string {
|
||||||
path := n.Module.String()
|
path := n.Module.String()
|
||||||
addr := n.Addr.String()
|
addr := n.Addr.String() + " (expand)"
|
||||||
|
|
||||||
if path != "" {
|
if path != "" {
|
||||||
return path + "." + addr
|
return path + "." + addr
|
||||||
}
|
}
|
||||||
|
@ -40,27 +41,27 @@ func (n *NodePlannableLocal) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeModulePath
|
// GraphNodeModulePath
|
||||||
func (n *NodePlannableLocal) ModulePath() addrs.Module {
|
func (n *nodeExpandLocal) ModulePath() addrs.Module {
|
||||||
return n.Module
|
return n.Module
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemovableIfNotTargeted
|
// RemovableIfNotTargeted
|
||||||
func (n *NodePlannableLocal) RemoveIfNotTargeted() bool {
|
func (n *nodeExpandLocal) RemoveIfNotTargeted() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeReferenceable
|
// GraphNodeReferenceable
|
||||||
func (n *NodePlannableLocal) ReferenceableAddrs() []addrs.Referenceable {
|
func (n *nodeExpandLocal) ReferenceableAddrs() []addrs.Referenceable {
|
||||||
return []addrs.Referenceable{n.Addr}
|
return []addrs.Referenceable{n.Addr}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeReferencer
|
// GraphNodeReferencer
|
||||||
func (n *NodePlannableLocal) References() []*addrs.Reference {
|
func (n *nodeExpandLocal) References() []*addrs.Reference {
|
||||||
refs, _ := lang.ReferencesInExpr(n.Config.Expr)
|
refs, _ := lang.ReferencesInExpr(n.Config.Expr)
|
||||||
return appendResourceDestroyReferences(refs)
|
return appendResourceDestroyReferences(refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodePlannableLocal) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
func (n *nodeExpandLocal) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
||||||
var g Graph
|
var g Graph
|
||||||
expander := ctx.InstanceExpander()
|
expander := ctx.InstanceExpander()
|
||||||
for _, module := range expander.ExpandModule(n.Module) {
|
for _, module := range expander.ExpandModule(n.Module) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *nodeExpandModule) Name() string {
|
func (n *nodeExpandModule) Name() string {
|
||||||
return n.Addr.String()
|
return n.Addr.String() + " (expand)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeModulePath implementation
|
// GraphNodeModulePath implementation
|
||||||
|
|
|
@ -49,7 +49,7 @@ func (n *nodeExpandModuleVariable) DynamicExpand(ctx EvalContext) (*Graph, error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *nodeExpandModuleVariable) Name() string {
|
func (n *nodeExpandModuleVariable) Name() string {
|
||||||
return fmt.Sprintf("%s.%s", n.Module, n.Addr.String())
|
return fmt.Sprintf("%s.%s (expand)", n.Module, n.Addr.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeModulePath
|
// GraphNodeModulePath
|
||||||
|
|
|
@ -10,28 +10,28 @@ import (
|
||||||
"github.com/hashicorp/terraform/lang"
|
"github.com/hashicorp/terraform/lang"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodePlannableOutput is the placeholder for an output that has not yet had
|
// nodeExpandOutput is the placeholder for an output that has not yet had
|
||||||
// its module path expanded.
|
// its module path expanded.
|
||||||
type NodePlannableOutput struct {
|
type nodeExpandOutput struct {
|
||||||
Addr addrs.OutputValue
|
Addr addrs.OutputValue
|
||||||
Module addrs.Module
|
Module addrs.Module
|
||||||
Config *configs.Output
|
Config *configs.Output
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ RemovableIfNotTargeted = (*NodePlannableOutput)(nil)
|
_ RemovableIfNotTargeted = (*nodeExpandOutput)(nil)
|
||||||
_ GraphNodeReferenceable = (*NodePlannableOutput)(nil)
|
_ GraphNodeReferenceable = (*nodeExpandOutput)(nil)
|
||||||
_ GraphNodeReferencer = (*NodePlannableOutput)(nil)
|
_ GraphNodeReferencer = (*nodeExpandOutput)(nil)
|
||||||
_ GraphNodeDynamicExpandable = (*NodePlannableOutput)(nil)
|
_ GraphNodeDynamicExpandable = (*nodeExpandOutput)(nil)
|
||||||
_ graphNodeTemporaryValue = (*NodeApplyableOutput)(nil)
|
_ graphNodeTemporaryValue = (*NodeApplyableOutput)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *NodePlannableOutput) temporaryValue() bool {
|
func (n *nodeExpandOutput) temporaryValue() bool {
|
||||||
// this must always be evaluated if it is a root module output
|
// this must always be evaluated if it is a root module output
|
||||||
return !n.Module.IsRoot()
|
return !n.Module.IsRoot()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodePlannableOutput) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
func (n *nodeExpandOutput) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
||||||
var g Graph
|
var g Graph
|
||||||
expander := ctx.InstanceExpander()
|
expander := ctx.InstanceExpander()
|
||||||
for _, module := range expander.ExpandModule(n.Module) {
|
for _, module := range expander.ExpandModule(n.Module) {
|
||||||
|
@ -45,9 +45,9 @@ func (n *NodePlannableOutput) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
||||||
return &g, nil
|
return &g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodePlannableOutput) Name() string {
|
func (n *nodeExpandOutput) Name() string {
|
||||||
path := n.Module.String()
|
path := n.Module.String()
|
||||||
addr := n.Addr.String()
|
addr := n.Addr.String() + " (expand)"
|
||||||
if path != "" {
|
if path != "" {
|
||||||
return path + "." + addr
|
return path + "." + addr
|
||||||
}
|
}
|
||||||
|
@ -55,12 +55,12 @@ func (n *NodePlannableOutput) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeModulePath
|
// GraphNodeModulePath
|
||||||
func (n *NodePlannableOutput) ModulePath() addrs.Module {
|
func (n *nodeExpandOutput) ModulePath() addrs.Module {
|
||||||
return n.Module
|
return n.Module
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeReferenceable
|
// GraphNodeReferenceable
|
||||||
func (n *NodePlannableOutput) ReferenceableAddrs() []addrs.Referenceable {
|
func (n *nodeExpandOutput) ReferenceableAddrs() []addrs.Referenceable {
|
||||||
// An output in the root module can't be referenced at all.
|
// An output in the root module can't be referenced at all.
|
||||||
if n.Module.IsRoot() {
|
if n.Module.IsRoot() {
|
||||||
return nil
|
return nil
|
||||||
|
@ -80,7 +80,7 @@ func (n *NodePlannableOutput) ReferenceableAddrs() []addrs.Referenceable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeReferenceOutside implementation
|
// GraphNodeReferenceOutside implementation
|
||||||
func (n *NodePlannableOutput) ReferenceOutside() (selfPath, referencePath addrs.Module) {
|
func (n *nodeExpandOutput) ReferenceOutside() (selfPath, referencePath addrs.Module) {
|
||||||
// Output values have their expressions resolved in the context of the
|
// Output values have their expressions resolved in the context of the
|
||||||
// module where they are defined.
|
// module where they are defined.
|
||||||
referencePath = n.Module
|
referencePath = n.Module
|
||||||
|
@ -92,17 +92,17 @@ func (n *NodePlannableOutput) ReferenceOutside() (selfPath, referencePath addrs.
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeReferencer
|
// GraphNodeReferencer
|
||||||
func (n *NodePlannableOutput) References() []*addrs.Reference {
|
func (n *nodeExpandOutput) References() []*addrs.Reference {
|
||||||
return appendResourceDestroyReferences(referencesForOutput(n.Config))
|
return appendResourceDestroyReferences(referencesForOutput(n.Config))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemovableIfNotTargeted
|
// RemovableIfNotTargeted
|
||||||
func (n *NodePlannableOutput) RemoveIfNotTargeted() bool {
|
func (n *nodeExpandOutput) RemoveIfNotTargeted() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeTargetDownstream
|
// GraphNodeTargetDownstream
|
||||||
func (n *NodePlannableOutput) TargetDownstream(targetedDeps, untargetedDeps dag.Set) bool {
|
func (n *nodeExpandOutput) TargetDownstream(targetedDeps, untargetedDeps dag.Set) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (n *nodeExpandApplyableResource) References() []*addrs.Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *nodeExpandApplyableResource) Name() string {
|
func (n *nodeExpandApplyableResource) Name() string {
|
||||||
return n.NodeAbstractResource.Name() + " (prepare state)"
|
return n.NodeAbstractResource.Name() + " (expand)"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *nodeExpandApplyableResource) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
func (n *nodeExpandApplyableResource) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
||||||
|
|
|
@ -31,6 +31,10 @@ var (
|
||||||
_ GraphNodeAttachResourceConfig = (*nodeExpandPlannableResource)(nil)
|
_ GraphNodeAttachResourceConfig = (*nodeExpandPlannableResource)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (n *nodeExpandPlannableResource) Name() string {
|
||||||
|
return n.NodeAbstractResource.Name() + " (expand)"
|
||||||
|
}
|
||||||
|
|
||||||
// GraphNodeDestroyerCBD
|
// GraphNodeDestroyerCBD
|
||||||
func (n *nodeExpandPlannableResource) CreateBeforeDestroy() bool {
|
func (n *nodeExpandPlannableResource) CreateBeforeDestroy() bool {
|
||||||
if n.ForceCreateBeforeDestroy != nil {
|
if n.ForceCreateBeforeDestroy != nil {
|
||||||
|
|
|
@ -36,6 +36,10 @@ var (
|
||||||
_ GraphNodeAttachDependencies = (*nodeExpandRefreshableManagedResource)(nil)
|
_ GraphNodeAttachDependencies = (*nodeExpandRefreshableManagedResource)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (n *nodeExpandRefreshableManagedResource) Name() string {
|
||||||
|
return n.NodeAbstractResource.Name() + " (expand)"
|
||||||
|
}
|
||||||
|
|
||||||
// GraphNodeAttachDependencies
|
// GraphNodeAttachDependencies
|
||||||
func (n *nodeExpandRefreshableManagedResource) AttachDependencies(deps []addrs.ConfigResource) {
|
func (n *nodeExpandRefreshableManagedResource) AttachDependencies(deps []addrs.ConfigResource) {
|
||||||
n.Dependencies = deps
|
n.Dependencies = deps
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (t *LocalTransformer) transformModule(g *Graph, c *configs.Config) error {
|
||||||
|
|
||||||
for _, local := range c.Module.Locals {
|
for _, local := range c.Module.Locals {
|
||||||
addr := addrs.LocalValue{Name: local.Name}
|
addr := addrs.LocalValue{Name: local.Name}
|
||||||
node := &NodePlannableLocal{
|
node := &nodeExpandLocal{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Module: c.Path,
|
Module: c.Path,
|
||||||
Config: local,
|
Config: local,
|
||||||
|
|
|
@ -58,10 +58,10 @@ func TestModuleVariableTransformer_nested(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testTransformModuleVarBasicStr = `
|
const testTransformModuleVarBasicStr = `
|
||||||
module.child.var.value
|
module.child.var.value (expand)
|
||||||
`
|
`
|
||||||
|
|
||||||
const testTransformModuleVarNestedStr = `
|
const testTransformModuleVarNestedStr = `
|
||||||
module.child.module.child.var.value
|
module.child.module.child.var.value (expand)
|
||||||
module.child.var.value
|
module.child.var.value (expand)
|
||||||
`
|
`
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (t *OutputTransformer) transform(g *Graph, c *configs.Config) error {
|
||||||
// into NodeApplyableOutputs to reflect possible expansion
|
// into NodeApplyableOutputs to reflect possible expansion
|
||||||
// through the presence of "count" or "for_each" on the modules.
|
// through the presence of "count" or "for_each" on the modules.
|
||||||
for _, o := range c.Module.Outputs {
|
for _, o := range c.Module.Outputs {
|
||||||
node := &NodePlannableOutput{
|
node := &nodeExpandOutput{
|
||||||
Addr: addrs.OutputValue{Name: o.Name},
|
Addr: addrs.OutputValue{Name: o.Name},
|
||||||
Module: c.Path,
|
Module: c.Path,
|
||||||
Config: o,
|
Config: o,
|
||||||
|
@ -67,7 +67,7 @@ func (t *DestroyOutputTransformer) Transform(g *Graph) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range g.Vertices() {
|
for _, v := range g.Vertices() {
|
||||||
output, ok := v.(*NodePlannableOutput)
|
output, ok := v.(*nodeExpandOutput)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,12 +118,12 @@ func TestTargetsTransformer_downstream(t *testing.T) {
|
||||||
// outputs that descend from it are also targeted.
|
// outputs that descend from it are also targeted.
|
||||||
expected := strings.TrimSpace(`
|
expected := strings.TrimSpace(`
|
||||||
module.child.module.grandchild.aws_instance.foo
|
module.child.module.grandchild.aws_instance.foo
|
||||||
module.child.module.grandchild.output.id
|
module.child.module.grandchild.output.id (expand)
|
||||||
module.child.module.grandchild.aws_instance.foo
|
module.child.module.grandchild.aws_instance.foo
|
||||||
module.child.output.grandchild_id
|
module.child.output.grandchild_id (expand)
|
||||||
module.child.module.grandchild.output.id
|
module.child.module.grandchild.output.id (expand)
|
||||||
output.grandchild_id
|
output.grandchild_id (expand)
|
||||||
module.child.output.grandchild_id
|
module.child.output.grandchild_id (expand)
|
||||||
`)
|
`)
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("bad:\n\nexpected:\n%s\n\ngot:\n%s\n", expected, actual)
|
t.Fatalf("bad:\n\nexpected:\n%s\n\ngot:\n%s\n", expected, actual)
|
||||||
|
@ -189,12 +189,12 @@ func TestTargetsTransformer_wholeModule(t *testing.T) {
|
||||||
// outputs that descend from it are also targeted.
|
// outputs that descend from it are also targeted.
|
||||||
expected := strings.TrimSpace(`
|
expected := strings.TrimSpace(`
|
||||||
module.child.module.grandchild.aws_instance.foo
|
module.child.module.grandchild.aws_instance.foo
|
||||||
module.child.module.grandchild.output.id
|
module.child.module.grandchild.output.id (expand)
|
||||||
module.child.module.grandchild.aws_instance.foo
|
module.child.module.grandchild.aws_instance.foo
|
||||||
module.child.output.grandchild_id
|
module.child.output.grandchild_id (expand)
|
||||||
module.child.module.grandchild.output.id
|
module.child.module.grandchild.output.id (expand)
|
||||||
output.grandchild_id
|
output.grandchild_id (expand)
|
||||||
module.child.output.grandchild_id
|
module.child.output.grandchild_id (expand)
|
||||||
`)
|
`)
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("bad:\n\nexpected:\n%s\n\ngot:\n%s\n", expected, actual)
|
t.Fatalf("bad:\n\nexpected:\n%s\n\ngot:\n%s\n", expected, actual)
|
||||||
|
|
Loading…
Reference in New Issue