mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
remove some destroy special cases
We no longer need special cases for most things during a full destroy, so remove those from the graph transformations. The only remaining cases are: - remove the root outputs, so destroy ends up with a clean state - reverse the target deps when targeting a destroy.
This commit is contained in:
parent
8c5853ee4e
commit
d4d99be2db
@ -168,16 +168,10 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
||||
Config: b.Config,
|
||||
State: b.State,
|
||||
Schemas: b.Schemas,
|
||||
Destroy: b.Destroy,
|
||||
},
|
||||
|
||||
GraphTransformIf(
|
||||
func() bool { return b.Destroy },
|
||||
GraphTransformMulti(
|
||||
// Create a destroy node for outputs to remove them from the state.
|
||||
&DestroyOutputTransformer{},
|
||||
),
|
||||
),
|
||||
// Create a destroy node for outputs to remove them from the state.
|
||||
&DestroyOutputTransformer{Destroy: b.Destroy},
|
||||
|
||||
// Prune unreferenced values, which may have interpolations that can't
|
||||
// be resolved.
|
||||
|
@ -134,16 +134,9 @@ type CBDEdgeTransformer struct {
|
||||
// obtain schema information from providers and provisioners so we can
|
||||
// properly resolve implicit dependencies.
|
||||
Schemas *Schemas
|
||||
|
||||
// If the operation is a simple destroy, no transformation is done.
|
||||
Destroy bool
|
||||
}
|
||||
|
||||
func (t *CBDEdgeTransformer) Transform(g *Graph) error {
|
||||
if t.Destroy {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Go through and reverse any destroy edges
|
||||
for _, v := range g.Vertices() {
|
||||
dn, ok := v.(GraphNodeDestroyerCBD)
|
||||
|
@ -60,9 +60,15 @@ func (t *OutputTransformer) transform(g *Graph, c *configs.Config) error {
|
||||
// outputs during destroy. We need to do this to ensure that no stale outputs
|
||||
// are ever left in the state.
|
||||
type DestroyOutputTransformer struct {
|
||||
Destroy bool
|
||||
}
|
||||
|
||||
func (t *DestroyOutputTransformer) Transform(g *Graph) error {
|
||||
// Only clean root outputs on a full destroy
|
||||
if !t.Destroy {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, v := range g.Vertices() {
|
||||
output, ok := v.(*NodeApplyableOutput)
|
||||
if !ok {
|
||||
|
Loading…
Reference in New Issue
Block a user