terraform: remove DisableReduce from refresh, plan and apply graphs (#25824)

This commit is contained in:
Kristin Laemmert 2020-08-14 14:13:33 -04:00 committed by GitHub
parent b5f4f9a96e
commit c9f710ac29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 63 deletions

View File

@ -40,9 +40,6 @@ type ApplyGraphBuilder struct {
// outputs should go into the diff so that this is unnecessary.
Targets []addrs.Targetable
// DisableReduce, if true, will not reduce the graph. Great for testing.
DisableReduce bool
// Destroy, if true, represents a pure destroy operation
Destroy bool
@ -194,12 +191,10 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
// close the root module
&CloseRootModuleTransformer{},
}
if !b.DisableReduce {
// Perform the transitive reduction to make our graph a bit
// more sane if possible (it usually is possible).
steps = append(steps, &TransitiveReductionTransformer{})
&TransitiveReductionTransformer{},
}
return steps

View File

@ -184,11 +184,10 @@ func TestApplyGraphBuilder_doubleCBD(t *testing.T) {
}
b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-double-cbd"),
Changes: changes,
Components: simpleMockComponentFactory(),
Schemas: simpleTestSchemas(),
DisableReduce: true,
Config: testModule(t, "graph-builder-apply-double-cbd"),
Changes: changes,
Components: simpleMockComponentFactory(),
Schemas: simpleTestSchemas(),
}
g, err := b.Build(addrs.RootModuleInstance)
@ -279,12 +278,11 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
)
b := &ApplyGraphBuilder{
Config: testModule(t, "empty"),
Changes: changes,
State: state,
Components: simpleMockComponentFactory(),
Schemas: simpleTestSchemas(),
DisableReduce: true,
Config: testModule(t, "empty"),
Changes: changes,
State: state,
Components: simpleMockComponentFactory(),
Schemas: simpleTestSchemas(),
}
g, diags := b.Build(addrs.RootModuleInstance)

View File

@ -39,9 +39,6 @@ type PlanGraphBuilder struct {
// Targets are resources to target
Targets []addrs.Targetable
// DisableReduce, if true, will not reduce the graph. Great for testing.
DisableReduce bool
// Validate will do structural validation of the graph.
Validate bool
@ -174,12 +171,10 @@ func (b *PlanGraphBuilder) Steps() []GraphTransformer {
// Close the root module
&CloseRootModuleTransformer{},
}
if !b.DisableReduce {
// Perform the transitive reduction to make our graph a bit
// more sane if possible (it usually is possible).
steps = append(steps, &TransitiveReductionTransformer{})
&TransitiveReductionTransformer{},
}
return steps

View File

@ -49,7 +49,6 @@ func TestPlanGraphBuilder(t *testing.T) {
addrs.NewDefaultProvider("openstack"): openstackProvider.GetSchemaReturn,
},
},
DisableReduce: true,
}
g, err := b.Build(addrs.RootModuleInstance)
@ -105,7 +104,6 @@ func TestPlanGraphBuilder_dynamicBlock(t *testing.T) {
addrs.NewDefaultProvider("test"): provider.GetSchemaReturn,
},
},
DisableReduce: true,
}
g, err := b.Build(addrs.RootModuleInstance)
@ -125,15 +123,9 @@ func TestPlanGraphBuilder_dynamicBlock(t *testing.T) {
actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(`
meta.count-boundary (EachMode fixup)
provider["registry.terraform.io/hashicorp/test"]
test_thing.a (expand)
test_thing.b (expand)
test_thing.c (expand)
provider["registry.terraform.io/hashicorp/test"]
provider["registry.terraform.io/hashicorp/test"] (close)
provider["registry.terraform.io/hashicorp/test"]
test_thing.a (expand)
test_thing.b (expand)
test_thing.c (expand)
root
meta.count-boundary (EachMode fixup)
@ -143,7 +135,6 @@ test_thing.a (expand)
test_thing.b (expand)
provider["registry.terraform.io/hashicorp/test"]
test_thing.c (expand)
provider["registry.terraform.io/hashicorp/test"]
test_thing.a (expand)
test_thing.b (expand)
`)
@ -184,7 +175,6 @@ func TestPlanGraphBuilder_attrAsBlocks(t *testing.T) {
addrs.NewDefaultProvider("test"): provider.GetSchemaReturn,
},
},
DisableReduce: true,
}
g, err := b.Build(addrs.RootModuleInstance)
@ -204,13 +194,9 @@ func TestPlanGraphBuilder_attrAsBlocks(t *testing.T) {
actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(`
meta.count-boundary (EachMode fixup)
provider["registry.terraform.io/hashicorp/test"]
test_thing.a (expand)
test_thing.b (expand)
provider["registry.terraform.io/hashicorp/test"]
provider["registry.terraform.io/hashicorp/test"] (close)
provider["registry.terraform.io/hashicorp/test"]
test_thing.a (expand)
test_thing.b (expand)
root
meta.count-boundary (EachMode fixup)
@ -218,7 +204,6 @@ root
test_thing.a (expand)
provider["registry.terraform.io/hashicorp/test"]
test_thing.b (expand)
provider["registry.terraform.io/hashicorp/test"]
test_thing.a (expand)
`)
if actual != expected {
@ -271,7 +256,6 @@ func TestPlanGraphBuilder_forEach(t *testing.T) {
addrs.NewDefaultProvider("aws"): awsProvider.GetSchemaReturn,
},
},
DisableReduce: true,
}
g, err := b.Build(addrs.RootModuleInstance)
@ -295,25 +279,16 @@ func TestPlanGraphBuilder_forEach(t *testing.T) {
const testPlanGraphBuilderStr = `
aws_instance.web (expand)
aws_security_group.firewall (expand)
provider["registry.terraform.io/hashicorp/aws"]
var.foo
aws_load_balancer.weblb (expand)
aws_instance.web (expand)
provider["registry.terraform.io/hashicorp/aws"]
aws_security_group.firewall (expand)
provider["registry.terraform.io/hashicorp/aws"]
local.instance_id (expand)
aws_instance.web (expand)
meta.count-boundary (EachMode fixup)
aws_instance.web (expand)
aws_load_balancer.weblb (expand)
aws_security_group.firewall (expand)
local.instance_id (expand)
openstack_floating_ip.random (expand)
output.instance_id (expand)
provider["registry.terraform.io/hashicorp/aws"]
provider["registry.terraform.io/hashicorp/openstack"]
var.foo
openstack_floating_ip.random (expand)
provider["registry.terraform.io/hashicorp/openstack"]
output.instance_id (expand)
@ -321,14 +296,10 @@ output.instance_id (expand)
provider["registry.terraform.io/hashicorp/aws"]
openstack_floating_ip.random (expand)
provider["registry.terraform.io/hashicorp/aws"] (close)
aws_instance.web (expand)
aws_load_balancer.weblb (expand)
aws_security_group.firewall (expand)
provider["registry.terraform.io/hashicorp/aws"]
provider["registry.terraform.io/hashicorp/openstack"]
provider["registry.terraform.io/hashicorp/openstack"] (close)
openstack_floating_ip.random (expand)
provider["registry.terraform.io/hashicorp/openstack"]
root
meta.count-boundary (EachMode fixup)
provider["registry.terraform.io/hashicorp/aws"] (close)
@ -342,7 +313,6 @@ aws_instance.bar2 (expand)
provider["registry.terraform.io/hashicorp/aws"]
aws_instance.bat (expand)
aws_instance.boo (expand)
provider["registry.terraform.io/hashicorp/aws"]
aws_instance.baz (expand)
provider["registry.terraform.io/hashicorp/aws"]
aws_instance.boo (expand)
@ -354,18 +324,14 @@ meta.count-boundary (EachMode fixup)
aws_instance.bar2 (expand)
aws_instance.bat (expand)
aws_instance.baz (expand)
aws_instance.boo (expand)
aws_instance.foo (expand)
provider["registry.terraform.io/hashicorp/aws"]
provider["registry.terraform.io/hashicorp/aws"]
provider["registry.terraform.io/hashicorp/aws"] (close)
aws_instance.bar (expand)
aws_instance.bar2 (expand)
aws_instance.bat (expand)
aws_instance.baz (expand)
aws_instance.boo (expand)
aws_instance.foo (expand)
provider["registry.terraform.io/hashicorp/aws"]
root
meta.count-boundary (EachMode fixup)
provider["registry.terraform.io/hashicorp/aws"] (close)

View File

@ -41,9 +41,6 @@ type RefreshGraphBuilder struct {
// Targets are resources to target
Targets []addrs.Targetable
// DisableReduce, if true, will not reduce the graph. Great for testing.
DisableReduce bool
// Validate will do structural validation of the graph.
Validate bool
}
@ -183,12 +180,10 @@ func (b *RefreshGraphBuilder) Steps() []GraphTransformer {
// Close root module
&CloseRootModuleTransformer{},
}
if !b.DisableReduce {
// Perform the transitive reduction to make our graph a bit
// more sane if possible (it usually is possible).
steps = append(steps, &TransitiveReductionTransformer{})
&TransitiveReductionTransformer{},
}
return steps