Skip to content

Commit e36ee75

Browse files
committed
minor cleanup from review
1 parent ec476af commit e36ee75

6 files changed

Lines changed: 22 additions & 25 deletions

File tree

‎internal/terraform/context_apply2_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ variable "in" {
923923
type = map(string)
924924
default = {
925925
"a" = "first"
926-
"b" = "second"
926+
"b" = "second"
927927
}
928928
}
929929

‎internal/terraform/graph_builder_plan.go‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,27 @@ func (b *PlanGraphBuilder) Steps() []GraphTransformer {
8282
steps := []GraphTransformer{
8383
// Creates all the resources represented in the config
8484
&ConfigTransformer{
85-
Concrete: b.ConcreteResource,
86-
Config: b.Config,
87-
destroyPlan: b.destroy,
85+
Concrete: b.ConcreteResource,
86+
Config: b.Config,
87+
skip: b.destroy,
8888
},
8989

9090
// Add dynamic values
9191
&RootVariableTransformer{Config: b.Config, RawValues: b.RootVariableValues},
9292
&ModuleVariableTransformer{Config: b.Config},
9393
&LocalTransformer{Config: b.Config},
9494
&OutputTransformer{
95-
Config: b.Config,
96-
RefreshOnly: b.skipPlanChanges,
97-
destroyPlan: b.destroy,
95+
Config: b.Config,
96+
RefreshOnly: b.skipPlanChanges,
97+
removeRootOutputs: b.destroy,
9898
},
9999

100100
// Add orphan resources
101101
&OrphanResourceInstanceTransformer{
102-
Concrete: b.ConcreteResourceOrphan,
103-
State: b.State,
104-
Config: b.Config,
105-
destroyPlan: b.destroy,
102+
Concrete: b.ConcreteResourceOrphan,
103+
State: b.State,
104+
Config: b.Config,
105+
skip: b.destroy,
106106
},
107107

108108
// We also need nodes for any deposed instance objects present in the

‎internal/terraform/transform_config.go‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ type ConfigTransformer struct {
2929
ModeFilter bool
3030
Mode addrs.ResourceMode
3131

32-
// destroyPlan indicated this is being called from a destroy plan.
33-
destroyPlan bool
32+
// Do not apply this transformer.
33+
skip bool
3434
}
3535

3636
func (t *ConfigTransformer) Transform(g *Graph) error {
37-
// If no configuration is available, we don't do anything
38-
if t.Config == nil {
37+
if t.skip {
3938
return nil
4039
}
4140

42-
// Configured resource are not added for a destroy plan
43-
if t.destroyPlan {
41+
// If no configuration is available, we don't do anything
42+
if t.Config == nil {
4443
return nil
4544
}
4645

‎internal/terraform/transform_destroy_edge.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"log"
55

66
"github.com/hashicorp/terraform/internal/addrs"
7-
87
"github.com/hashicorp/terraform/internal/dag"
98
)
109

‎internal/terraform/transform_orphan_resource.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ type OrphanResourceInstanceTransformer struct {
2727
// the appropriate note in this tree using the path in each node.
2828
Config *configs.Config
2929

30-
// There are no orphans when doing a full destroy
31-
destroyPlan bool
30+
// Do not apply this transformer
31+
skip bool
3232
}
3333

3434
func (t *OrphanResourceInstanceTransformer) Transform(g *Graph) error {
35-
if t.destroyPlan {
36-
// everything is being destroyed, so don't worry about orphaned instances
35+
if t.skip {
3736
return nil
3837
}
3938

‎internal/terraform/transform_output.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type OutputTransformer struct {
2121

2222
// If this is a planned destroy, root outputs are still in the configuration
2323
// so we need to record that we wish to remove them
24-
destroyPlan bool
24+
removeRootOutputs bool
2525

2626
// Refresh-only mode means that any failing output preconditions are
2727
// reported as warnings rather than errors
@@ -66,7 +66,7 @@ func (t *OutputTransformer) transform(g *Graph, c *configs.Config) error {
6666
}
6767
}
6868

69-
destroy := t.destroyPlan
69+
destroy := t.removeRootOutputs
7070
if rootChange != nil {
7171
destroy = rootChange.Action == plans.Delete
7272
}
@@ -95,7 +95,7 @@ func (t *OutputTransformer) transform(g *Graph, c *configs.Config) error {
9595
Addr: addr,
9696
Module: c.Path,
9797
Config: o,
98-
Destroy: t.destroyPlan,
98+
Destroy: t.removeRootOutputs,
9999
RefreshOnly: t.RefreshOnly,
100100
}
101101
}

0 commit comments

Comments
 (0)