mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
minor cleanup from review
This commit is contained in:
parent
ec476af655
commit
e36ee757a5
@ -923,7 +923,7 @@ variable "in" {
|
||||
type = map(string)
|
||||
default = {
|
||||
"a" = "first"
|
||||
"b" = "second"
|
||||
"b" = "second"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/addrs"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/dag"
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user