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