core: flatten orphan modules

This commit is contained in:
Paul Hinze 2015-05-13 11:33:29 -05:00
parent 75f000e0cc
commit a5e4e3de59
1 changed files with 24 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package terraform
import (
"fmt"
"log"
"github.com/hashicorp/terraform/dag"
@ -59,3 +60,26 @@ func (n *GraphNodeBasicSubgraph) Name() string {
func (n *GraphNodeBasicSubgraph) Subgraph() *Graph {
return n.Graph
}
func (n *GraphNodeBasicSubgraph) Flatten(p []string) (dag.Vertex, error) {
return &graphNodeBasicSubgraphFlat{
GraphNodeBasicSubgraph: n,
PathValue: p,
}, nil
}
// Same as GraphNodeBasicSubgraph, but for flattening
type graphNodeBasicSubgraphFlat struct {
*GraphNodeBasicSubgraph
PathValue []string
}
func (n *graphNodeBasicSubgraphFlat) Name() string {
return fmt.Sprintf(
"%s.%s", modulePrefixStr(n.PathValue), n.GraphNodeBasicSubgraph.Name())
}
func (n *graphNodeBasicSubgraphFlat) Path() []string {
return n.PathValue
}