dag: rename to this

This commit is contained in:
Mitchell Hashimoto 2015-01-22 17:12:32 -08:00
parent 012dcca7d5
commit 87f4c3aae1
4 changed files with 18 additions and 18 deletions

View File

@ -1,4 +1,4 @@
package depgraph package dag
import ( import (
"bytes" "bytes"

View File

@ -6,12 +6,12 @@ import (
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/module" "github.com/hashicorp/terraform/config/module"
"github.com/hashicorp/terraform/depgraph2" "github.com/hashicorp/terraform/dag"
) )
// Graph takes a module tree and builds a logical graph of all the nodes // Graph takes a module tree and builds a logical graph of all the nodes
// in that module. // in that module.
func Graph2(mod *module.Tree) (*depgraph.Graph, error) { func Graph2(mod *module.Tree) (*dag.Graph, error) {
// A module is required and also must be completely loaded. // A module is required and also must be completely loaded.
if mod == nil { if mod == nil {
return nil, errors.New("module must not be nil") return nil, errors.New("module must not be nil")
@ -43,7 +43,7 @@ func Graph2(mod *module.Tree) (*depgraph.Graph, error) {
} }
// Build the full map of the var names to the nodes. // Build the full map of the var names to the nodes.
fullMap := make(map[string]depgraph.Node) fullMap := make(map[string]dag.Node)
for _, n := range nodes { for _, n := range nodes {
fullMap[n.VarName()] = n fullMap[n.VarName()] = n
} }
@ -53,7 +53,7 @@ func Graph2(mod *module.Tree) (*depgraph.Graph, error) {
// building the dep map based on the fullMap which contains the mapping // building the dep map based on the fullMap which contains the mapping
// of var names to the actual node with that name. // of var names to the actual node with that name.
for _, n := range nodes { for _, n := range nodes {
m := make(map[string]depgraph.Node) m := make(map[string]dag.Node)
for _, id := range n.Variables() { for _, id := range n.Variables() {
m[id] = fullMap[id] m[id] = fullMap[id]
} }
@ -62,7 +62,7 @@ func Graph2(mod *module.Tree) (*depgraph.Graph, error) {
} }
// Build the graph and return it // Build the graph and return it
g := &depgraph.Graph{Nodes: make([]depgraph.Node, 0, len(nodes))} g := &dag.Graph{Nodes: make([]dag.Node, 0, len(nodes))}
for _, n := range nodes { for _, n := range nodes {
g.Nodes = append(g.Nodes, n) g.Nodes = append(g.Nodes, n)
} }

View File

@ -4,14 +4,14 @@ import (
"fmt" "fmt"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/depgraph2" "github.com/hashicorp/terraform/dag"
) )
// graphNodeConfig is an interface that all graph nodes for the // graphNodeConfig is an interface that all graph nodes for the
// configuration graph need to implement in order to build the variable // configuration graph need to implement in order to build the variable
// dependencies properly. // dependencies properly.
type graphNodeConfig interface { type graphNodeConfig interface {
depgraph.Node dag.Node
// Variables returns the full list of variables that this node // Variables returns the full list of variables that this node
// depends on. The values within the slice should map to the VarName() // depends on. The values within the slice should map to the VarName()
@ -26,8 +26,8 @@ type graphNodeConfig interface {
// depMap and setDepMap are used to get and set the dependency map // depMap and setDepMap are used to get and set the dependency map
// for this node. This is used to modify the dependencies. The key of // for this node. This is used to modify the dependencies. The key of
// this map should be the VarName() of graphNodeConfig. // this map should be the VarName() of graphNodeConfig.
depMap() map[string]depgraph.Node depMap() map[string]dag.Node
setDepMap(map[string]depgraph.Node) setDepMap(map[string]dag.Node)
} }
// graphNodeConfigBasicDepMap is a struct that provides the Deps(), // graphNodeConfigBasicDepMap is a struct that provides the Deps(),
@ -35,11 +35,11 @@ type graphNodeConfig interface {
// interface. This struct is meant to be embedded into other nodes to get // interface. This struct is meant to be embedded into other nodes to get
// these features for free. // these features for free.
type graphNodeConfigBasicDepMap struct { type graphNodeConfigBasicDepMap struct {
DepMap map[string]depgraph.Node DepMap map[string]dag.Node
} }
func (n *graphNodeConfigBasicDepMap) Deps() []depgraph.Node { func (n *graphNodeConfigBasicDepMap) Deps() []dag.Node {
r := make([]depgraph.Node, 0, len(n.DepMap)) r := make([]dag.Node, 0, len(n.DepMap))
for _, v := range n.DepMap { for _, v := range n.DepMap {
if v != nil { if v != nil {
r = append(r, v) r = append(r, v)
@ -49,11 +49,11 @@ func (n *graphNodeConfigBasicDepMap) Deps() []depgraph.Node {
return r return r
} }
func (n *graphNodeConfigBasicDepMap) depMap() map[string]depgraph.Node { func (n *graphNodeConfigBasicDepMap) depMap() map[string]dag.Node {
return n.DepMap return n.DepMap
} }
func (n *graphNodeConfigBasicDepMap) setDepMap(m map[string]depgraph.Node) { func (n *graphNodeConfigBasicDepMap) setDepMap(m map[string]dag.Node) {
n.DepMap = m n.DepMap = m
} }

View File

@ -3,11 +3,11 @@ package terraform
import ( import (
"testing" "testing"
"github.com/hashicorp/terraform/depgraph2" "github.com/hashicorp/terraform/dag"
) )
func TestGraphNodeConfigResource_impl(t *testing.T) { func TestGraphNodeConfigResource_impl(t *testing.T) {
var _ depgraph.Node = new(GraphNodeConfigResource) var _ dag.Node = new(GraphNodeConfigResource)
var _ depgraph.NamedNode = new(GraphNodeConfigResource) var _ dag.NamedNode = new(GraphNodeConfigResource)
var _ graphNodeConfig = new(GraphNodeConfigResource) var _ graphNodeConfig = new(GraphNodeConfigResource)
} }