terraform: hook up the proxies

This commit is contained in:
Mitchell Hashimoto 2015-05-01 11:45:42 -07:00
parent 7d28e980a5
commit e544e1d401
5 changed files with 66 additions and 0 deletions

View File

@ -94,6 +94,11 @@ func (n *GraphNodeConfigOutput) EvalTree() EvalNode {
}
}
// GraphNodeProxy impl.
func (n *GraphNodeConfigOutput) Proxy() bool {
return true
}
// GraphNodeConfigProvider represents a configured provider within the
// configuration graph. These are only immediately in the graph when an
// explicit `provider` configuration block is in the configuration.

View File

@ -283,6 +283,15 @@ func (n *graphNodeModuleFlatWrap) DependentOn() []string {
return result
}
func (n *graphNodeModuleFlatWrap) Proxy() bool {
pn, ok := n.graphNodeModuleWrappable.(GraphNodeProxy)
if !ok {
return false
}
return pn.Proxy()
}
func (n *graphNodeModuleFlatWrap) prefixList(result []string, prefix string) {
for i, v := range result {
result[i] = fmt.Sprintf("%s.%s", prefix, v)

View File

@ -13,6 +13,7 @@ func TestGraphNodeConfigOutput_impl(t *testing.T) {
var _ dag.NamedVertex = new(GraphNodeConfigOutput)
var _ graphNodeConfig = new(GraphNodeConfigOutput)
var _ GraphNodeOutput = new(GraphNodeConfigOutput)
var _ GraphNodeProxy = new(GraphNodeConfigOutput)
}
func TestGraphNodeConfigProvider_impl(t *testing.T) {
@ -113,4 +114,5 @@ func TestGraphNodeConfigVariable_impl(t *testing.T) {
var _ dag.NamedVertex = new(GraphNodeConfigVariable)
var _ graphNodeConfig = new(GraphNodeConfigVariable)
var _ GraphNodeVariable = new(GraphNodeConfigVariable)
var _ GraphNodeProxy = new(GraphNodeConfigVariable)
}

View File

@ -61,3 +61,8 @@ func (n *GraphNodeConfigVariable) VariableName() string {
func (n *GraphNodeConfigVariable) SetVariableValue(v *config.RawConfig) {
n.Value = v
}
// GraphNodeProxy impl.
func (n *GraphNodeConfigVariable) Proxy() bool {
return true
}

View File

@ -35,6 +35,37 @@ func TestFlattenTransformer(t *testing.T) {
}
}
func TestFlattenTransformer_withProxy(t *testing.T) {
mod := testModule(t, "transform-flatten")
var b BasicGraphBuilder
b = BasicGraphBuilder{
Steps: []GraphTransformer{
&ConfigTransformer{Module: mod},
&VertexTransformer{
Transforms: []GraphVertexTransformer{
&ExpandTransform{
Builder: &b,
},
},
},
&FlattenTransformer{},
&ProxyTransformer{},
},
}
g, err := b.Build(rootModulePath)
if err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(testTransformFlattenProxyStr)
if actual != expected {
t.Fatalf("bad:\n\n%s", actual)
}
}
const testTransformFlattenStr = `
aws_instance.parent
aws_instance.parent-output
@ -46,3 +77,17 @@ module.child.output.output
module.child.var.var
aws_instance.parent
`
const testTransformFlattenProxyStr = `
aws_instance.parent
aws_instance.parent-output
module.child.aws_instance.child
module.child.output.output
module.child.aws_instance.child
aws_instance.parent
module.child.var.var
module.child.output.output
module.child.aws_instance.child
module.child.var.var
aws_instance.parent
`