terraform: depends_on with count creates proper graph [GH-244]
This commit is contained in:
parent
7cfad67920
commit
28a2e7b979
|
@ -9,6 +9,7 @@ IMPROVEMENTS:
|
|||
BUG FIXES:
|
||||
|
||||
* core: Configuration parses when identifier and '=' have no space. [GH-243]
|
||||
* core: `depends_on` with `count` generates the proper graph. [GH-244]
|
||||
|
||||
## 0.2.0 (August 28, 2014)
|
||||
|
||||
|
|
|
@ -413,7 +413,7 @@ func graphAddExplicitDeps(g *depgraph.Graph) {
|
|||
continue
|
||||
}
|
||||
|
||||
rs[rn.Config.Id()] = n
|
||||
rs[rn.Resource.Id] = n
|
||||
if len(rn.Config.DependsOn) > 0 {
|
||||
depends = true
|
||||
}
|
||||
|
|
|
@ -66,6 +66,21 @@ func TestGraph_dependsOn(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGraph_dependsOnCount(t *testing.T) {
|
||||
config := testConfig(t, "graph-depends-on-count")
|
||||
|
||||
g, err := Graph(&GraphOpts{Config: config})
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(g.String())
|
||||
expected := strings.TrimSpace(testTerraformGraphDependsCountStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad:\n\n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGraph_state(t *testing.T) {
|
||||
config := testConfig(t, "graph-basic")
|
||||
state := &State{
|
||||
|
@ -372,6 +387,21 @@ root
|
|||
root -> aws_instance.web
|
||||
`
|
||||
|
||||
const testTerraformGraphDependsCountStr = `
|
||||
root: root
|
||||
aws_instance.db
|
||||
aws_instance.db -> aws_instance.db.0
|
||||
aws_instance.db -> aws_instance.db.1
|
||||
aws_instance.db.0
|
||||
aws_instance.db.0 -> aws_instance.web
|
||||
aws_instance.db.1
|
||||
aws_instance.db.1 -> aws_instance.web
|
||||
aws_instance.web
|
||||
root
|
||||
root -> aws_instance.db
|
||||
root -> aws_instance.web
|
||||
`
|
||||
|
||||
const testTerraformGraphDiffStr = `
|
||||
root: root
|
||||
aws_instance.foo
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
resource "aws_instance" "web" {}
|
||||
|
||||
resource "aws_instance" "db" {
|
||||
depends_on = ["aws_instance.web"]
|
||||
count = 2
|
||||
}
|
Loading…
Reference in New Issue