terraform: fix potential case where cycle is made
This commit is contained in:
parent
acc9cf0003
commit
2e777d87a2
|
@ -1,6 +1,8 @@
|
||||||
package depgraph
|
package depgraph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/digraph"
|
"github.com/hashicorp/terraform/digraph"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,6 +33,14 @@ func (d *Dependency) Tail() digraph.Node {
|
||||||
return d.Target
|
return d.Target
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Dependency) GoString() string {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"*Dependency{Name: %s, Source: %s, Target: %s}",
|
||||||
|
d.Name,
|
||||||
|
d.Source.Name,
|
||||||
|
d.Target.Name)
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Dependency) String() string {
|
func (d *Dependency) String() string {
|
||||||
return d.Name
|
return d.Name
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package depgraph
|
package depgraph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/digraph"
|
"github.com/hashicorp/terraform/digraph"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,6 +24,10 @@ func (n *Noun) Edges() []digraph.Edge {
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Noun) GoString() string {
|
||||||
|
return fmt.Sprintf("*%#v", *n)
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Noun) String() string {
|
func (n *Noun) String() string {
|
||||||
return n.Name
|
return n.Name
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,11 @@ func graphAddDiff(g *depgraph.Graph, d *Diff) error {
|
||||||
// dependencies. Look to see if they're managed.
|
// dependencies. Look to see if they're managed.
|
||||||
for _, dep := range deps {
|
for _, dep := range deps {
|
||||||
for _, n2 := range nlist {
|
for _, n2 := range nlist {
|
||||||
|
// Don't ever depend on ourselves
|
||||||
|
if n2.Name == n.Name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
rn2 := n2.Meta.(*GraphNodeResource)
|
rn2 := n2.Meta.(*GraphNodeResource)
|
||||||
if rn2.Resource.State.ID == dep.ID {
|
if rn2.Resource.State.ID == dep.ID {
|
||||||
n2.Deps = append(n2.Deps, &depgraph.Dependency{
|
n2.Deps = append(n2.Deps, &depgraph.Dependency{
|
||||||
|
|
Loading…
Reference in New Issue