terraform: only omit vars on full destroys
This commit is contained in:
parent
19b33326be
commit
6b2e0b938d
|
@ -153,7 +153,7 @@ func (b *BuiltinGraphBuilder) Steps(path []string) []GraphTransformer {
|
|||
if len(path) <= 1 {
|
||||
steps = append(steps,
|
||||
// Create the destruction nodes
|
||||
&DestroyTransformer{},
|
||||
&DestroyTransformer{FullDestroy: b.Destroy},
|
||||
&CreateBeforeDestroyTransformer{},
|
||||
b.conditional(&conditionalOpts{
|
||||
If: func() bool { return !b.Verbose },
|
||||
|
|
|
@ -62,7 +62,7 @@ func (n *GraphNodeConfigOutput) Proxy() bool {
|
|||
}
|
||||
|
||||
// GraphNodeDestroyEdgeInclude impl.
|
||||
func (n *GraphNodeConfigOutput) DestroyEdgeInclude() bool {
|
||||
func (n *GraphNodeConfigOutput) DestroyEdgeInclude(bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,14 @@ func (n *GraphNodeConfigVariable) VariableName() string {
|
|||
}
|
||||
|
||||
// GraphNodeDestroyEdgeInclude impl.
|
||||
func (n *GraphNodeConfigVariable) DestroyEdgeInclude() bool {
|
||||
func (n *GraphNodeConfigVariable) DestroyEdgeInclude(full bool) bool {
|
||||
// Don't include variables as dependencies in destroy nodes.
|
||||
// Destroy nodes don't interpolate anyways and this has a possibility
|
||||
// to create cycles. See GH-1835
|
||||
return false
|
||||
//
|
||||
// We include the variable on non-full destroys because it might
|
||||
// be used for count interpolation.
|
||||
return !full
|
||||
}
|
||||
|
||||
// GraphNodeProxy impl.
|
||||
|
|
|
@ -49,12 +49,14 @@ type GraphNodeDestroyPrunable interface {
|
|||
// as an edge within the destroy graph. This is usually done because it
|
||||
// might cause unnecessary cycles.
|
||||
type GraphNodeDestroyEdgeInclude interface {
|
||||
DestroyEdgeInclude() bool
|
||||
DestroyEdgeInclude(bool) bool
|
||||
}
|
||||
|
||||
// DestroyTransformer is a GraphTransformer that creates the destruction
|
||||
// nodes for things that _might_ be destroyed.
|
||||
type DestroyTransformer struct{}
|
||||
type DestroyTransformer struct {
|
||||
FullDestroy bool
|
||||
}
|
||||
|
||||
func (t *DestroyTransformer) Transform(g *Graph) error {
|
||||
var connect, remove []dag.Edge
|
||||
|
@ -111,7 +113,8 @@ func (t *DestroyTransformer) transform(
|
|||
for _, edgeRaw := range downEdges {
|
||||
// If this thing specifically requests to not be depended on
|
||||
// by destroy nodes, then don't.
|
||||
if i, ok := edgeRaw.(GraphNodeDestroyEdgeInclude); ok && !i.DestroyEdgeInclude() {
|
||||
if i, ok := edgeRaw.(GraphNodeDestroyEdgeInclude); ok &&
|
||||
!i.DestroyEdgeInclude(t.FullDestroy) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue