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:
James Bardin 2019-12-12 21:36:27 -05:00
parent 8c5853ee4e
commit d4d99be2db
3 changed files with 8 additions and 15 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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 {