terraform: skip outputs for destroy graphs

This commit is contained in:
Mitchell Hashimoto 2015-05-02 18:28:26 -07:00
parent 6afc14982a
commit cc0c208364
2 changed files with 15 additions and 5 deletions

View File

@ -61,6 +61,11 @@ func (n *GraphNodeConfigOutput) Proxy() bool {
return true
}
// GraphNodeDestroyEdgeInclude impl.
func (n *GraphNodeConfigOutput) DestroyEdgeInclude() bool {
return false
}
// GraphNodeFlattenable impl.
func (n *GraphNodeConfigOutput) Flatten(p []string) (dag.Vertex, error) {
return &GraphNodeConfigOutputFlat{

View File

@ -45,6 +45,13 @@ type GraphNodeDestroyPrunable interface {
DestroyInclude(*ModuleDiff, *ModuleState) bool
}
// GraphNodeEdgeInclude can be implemented to not include something
// as an edge within the destroy graph. This is usually done because it
// might cause unnecessary cycles.
type GraphNodeDestroyEdgeInclude interface {
DestroyEdgeInclude() bool
}
// DestroyTransformer is a GraphTransformer that creates the destruction
// nodes for things that _might_ be destroyed.
type DestroyTransformer struct{}
@ -102,11 +109,9 @@ func (t *DestroyTransformer) transform(
// Inherit all the edges from the old node
downEdges := g.DownEdges(v).List()
for _, edgeRaw := range downEdges {
// Don't inherit proxies. These are currently variables and
// outputs and don't affect destroys. In the future we should
// probably make this more obvious somehow (another interface?).
// Right now I'm not sure how.
if _, ok := edgeRaw.(GraphNodeProxy); ok {
// If this thing specifically requests to not be depended on
// by destroy nodes, then don't.
if i, ok := edgeRaw.(GraphNodeDestroyEdgeInclude); ok && !i.DestroyEdgeInclude() {
continue
}