minor cleanup from review

This commit is contained in:
James Bardin 2022-06-01 15:29:59 -04:00
parent ec476af655
commit e36ee757a5
6 changed files with 22 additions and 25 deletions

View File

@ -923,7 +923,7 @@ variable "in" {
type = map(string)
default = {
"a" = "first"
"b" = "second"
"b" = "second"
}
}

View File

@ -82,9 +82,9 @@ func (b *PlanGraphBuilder) Steps() []GraphTransformer {
steps := []GraphTransformer{
// Creates all the resources represented in the config
&ConfigTransformer{
Concrete: b.ConcreteResource,
Config: b.Config,
destroyPlan: b.destroy,
Concrete: b.ConcreteResource,
Config: b.Config,
skip: b.destroy,
},
// Add dynamic values
@ -92,17 +92,17 @@ func (b *PlanGraphBuilder) Steps() []GraphTransformer {
&ModuleVariableTransformer{Config: b.Config},
&LocalTransformer{Config: b.Config},
&OutputTransformer{
Config: b.Config,
RefreshOnly: b.skipPlanChanges,
destroyPlan: b.destroy,
Config: b.Config,
RefreshOnly: b.skipPlanChanges,
removeRootOutputs: b.destroy,
},
// Add orphan resources
&OrphanResourceInstanceTransformer{
Concrete: b.ConcreteResourceOrphan,
State: b.State,
Config: b.Config,
destroyPlan: b.destroy,
Concrete: b.ConcreteResourceOrphan,
State: b.State,
Config: b.Config,
skip: b.destroy,
},
// We also need nodes for any deposed instance objects present in the

View File

@ -29,18 +29,17 @@ type ConfigTransformer struct {
ModeFilter bool
Mode addrs.ResourceMode
// destroyPlan indicated this is being called from a destroy plan.
destroyPlan bool
// Do not apply this transformer.
skip bool
}
func (t *ConfigTransformer) Transform(g *Graph) error {
// If no configuration is available, we don't do anything
if t.Config == nil {
if t.skip {
return nil
}
// Configured resource are not added for a destroy plan
if t.destroyPlan {
// If no configuration is available, we don't do anything
if t.Config == nil {
return nil
}

View File

@ -4,7 +4,6 @@ import (
"log"
"github.com/hashicorp/terraform/internal/addrs"
"github.com/hashicorp/terraform/internal/dag"
)

View File

@ -27,13 +27,12 @@ type OrphanResourceInstanceTransformer struct {
// the appropriate note in this tree using the path in each node.
Config *configs.Config
// There are no orphans when doing a full destroy
destroyPlan bool
// Do not apply this transformer
skip bool
}
func (t *OrphanResourceInstanceTransformer) Transform(g *Graph) error {
if t.destroyPlan {
// everything is being destroyed, so don't worry about orphaned instances
if t.skip {
return nil
}

View File

@ -21,7 +21,7 @@ type OutputTransformer struct {
// If this is a planned destroy, root outputs are still in the configuration
// so we need to record that we wish to remove them
destroyPlan bool
removeRootOutputs bool
// Refresh-only mode means that any failing output preconditions are
// reported as warnings rather than errors
@ -66,7 +66,7 @@ func (t *OutputTransformer) transform(g *Graph, c *configs.Config) error {
}
}
destroy := t.destroyPlan
destroy := t.removeRootOutputs
if rootChange != nil {
destroy = rootChange.Action == plans.Delete
}
@ -95,7 +95,7 @@ func (t *OutputTransformer) transform(g *Graph, c *configs.Config) error {
Addr: addr,
Module: c.Path,
Config: o,
Destroy: t.destroyPlan,
Destroy: t.removeRootOutputs,
RefreshOnly: t.RefreshOnly,
}
}