terraform: expand modules in our builder
This commit is contained in:
parent
4692f9809f
commit
e2a3f78c08
|
@ -74,6 +74,13 @@ func (b *BuiltinGraphBuilder) Steps() []GraphTransformer {
|
||||||
&MissingProviderTransformer{Providers: b.Providers},
|
&MissingProviderTransformer{Providers: b.Providers},
|
||||||
&ProviderTransformer{},
|
&ProviderTransformer{},
|
||||||
&PruneProviderTransformer{},
|
&PruneProviderTransformer{},
|
||||||
|
&VertexTransformer{
|
||||||
|
Transforms: []GraphVertexTransformer{
|
||||||
|
&ExpandTransform{
|
||||||
|
Builder: b,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
&RootTransformer{},
|
&RootTransformer{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,24 @@ func TestBuiltinGraphBuilder(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This test tests that the graph builder properly expands modules.
|
||||||
|
func TestBuiltinGraphBuilder_modules(t *testing.T) {
|
||||||
|
b := &BuiltinGraphBuilder{
|
||||||
|
Root: testModule(t, "graph-builder-modules"),
|
||||||
|
}
|
||||||
|
|
||||||
|
g, err := b.Build(RootModulePath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := strings.TrimSpace(g.String())
|
||||||
|
expected := strings.TrimSpace(testBuiltinGraphBuilderModuleStr)
|
||||||
|
if actual != expected {
|
||||||
|
t.Fatalf("bad: %s", actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const testBuiltinGraphBuilderBasicStr = `
|
const testBuiltinGraphBuilderBasicStr = `
|
||||||
aws_instance.db
|
aws_instance.db
|
||||||
provider.aws
|
provider.aws
|
||||||
|
@ -37,3 +55,15 @@ aws_instance.web
|
||||||
provider.aws
|
provider.aws
|
||||||
provider.aws
|
provider.aws
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testBuiltinGraphBuilderModuleStr = `
|
||||||
|
aws_instance.web
|
||||||
|
aws_security_group.firewall
|
||||||
|
module.consul (expanded)
|
||||||
|
provider.aws
|
||||||
|
aws_security_group.firewall
|
||||||
|
provider.aws
|
||||||
|
module.consul (expanded)
|
||||||
|
aws_security_group.firewall
|
||||||
|
provider.aws
|
||||||
|
`
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
provider "aws" {}
|
||||||
|
resource "aws_instance" "server" {}
|
|
@ -0,0 +1,16 @@
|
||||||
|
module "consul" {
|
||||||
|
foo = "${aws_security_group.firewall.foo}"
|
||||||
|
source = "./consul"
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "aws" {}
|
||||||
|
|
||||||
|
resource "aws_security_group" "firewall" {}
|
||||||
|
|
||||||
|
resource "aws_instance" "web" {
|
||||||
|
security_groups = [
|
||||||
|
"foo",
|
||||||
|
"${aws_security_group.firewall.foo}",
|
||||||
|
"${module.consul.security_group}"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue