terraform: move resource orphan deps out of loop
This commit is contained in:
parent
7025c48165
commit
98683b44b8
|
@ -26,10 +26,10 @@ func (t *OrphanTransformer) Transform(g *Graph) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go over each resource orphan and add it to the graph.
|
// Go over each resource orphan and add it to the graph.
|
||||||
for _, k := range state.Orphans(t.Config) {
|
resourceOrphans := state.Orphans(t.Config)
|
||||||
g.ConnectTo(
|
resourceVertexes := make([]dag.Vertex, len(resourceOrphans))
|
||||||
g.Add(&graphNodeOrphanResource{ResourceName: k}),
|
for i, k := range resourceOrphans {
|
||||||
state.Resources[k].Dependencies)
|
resourceVertexes[i] = g.Add(&graphNodeOrphanResource{ResourceName: k})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go over each module orphan and add it to the graph. We store the
|
// Go over each module orphan and add it to the graph. We store the
|
||||||
|
@ -42,6 +42,15 @@ func (t *OrphanTransformer) Transform(g *Graph) error {
|
||||||
moduleStates[i] = t.State.ModuleByPath(path)
|
moduleStates[i] = t.State.ModuleByPath(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now do the dependencies. We do this _after_ adding all the orphan
|
||||||
|
// nodes above because there are cases in which the orphans themselves
|
||||||
|
// depend on other orphans.
|
||||||
|
|
||||||
|
// Resource dependencies
|
||||||
|
for i, v := range resourceVertexes {
|
||||||
|
g.ConnectTo(v, state.Resources[resourceOrphans[i]].Dependencies)
|
||||||
|
}
|
||||||
|
|
||||||
// Module dependencies
|
// Module dependencies
|
||||||
for i, v := range moduleVertexes {
|
for i, v := range moduleVertexes {
|
||||||
g.ConnectTo(v, moduleStates[i].Dependencies)
|
g.ConnectTo(v, moduleStates[i].Dependencies)
|
||||||
|
|
Loading…
Reference in New Issue