From 87f4c3aae1a4de33c8c5a5da060b405f6eda69e4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 22 Jan 2015 17:12:32 -0800 Subject: [PATCH] dag: rename to this --- {depgraph2 => dag}/graph.go | 2 +- terraform/graph_config.go | 10 +++++----- terraform/graph_config_node.go | 18 +++++++++--------- terraform/graph_config_node_test.go | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) rename {depgraph2 => dag}/graph.go (98%) diff --git a/depgraph2/graph.go b/dag/graph.go similarity index 98% rename from depgraph2/graph.go rename to dag/graph.go index 059f8ea97..a81a2c1a3 100644 --- a/depgraph2/graph.go +++ b/dag/graph.go @@ -1,4 +1,4 @@ -package depgraph +package dag import ( "bytes" diff --git a/terraform/graph_config.go b/terraform/graph_config.go index 75e34cbb5..cef24e0aa 100644 --- a/terraform/graph_config.go +++ b/terraform/graph_config.go @@ -6,12 +6,12 @@ import ( "github.com/hashicorp/terraform/config" "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 // 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. if mod == 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. - fullMap := make(map[string]depgraph.Node) + fullMap := make(map[string]dag.Node) for _, n := range nodes { 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 // of var names to the actual node with that name. for _, n := range nodes { - m := make(map[string]depgraph.Node) + m := make(map[string]dag.Node) for _, id := range n.Variables() { m[id] = fullMap[id] } @@ -62,7 +62,7 @@ func Graph2(mod *module.Tree) (*depgraph.Graph, error) { } // 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 { g.Nodes = append(g.Nodes, n) } diff --git a/terraform/graph_config_node.go b/terraform/graph_config_node.go index 2c181bee6..d36c2bc23 100644 --- a/terraform/graph_config_node.go +++ b/terraform/graph_config_node.go @@ -4,14 +4,14 @@ import ( "fmt" "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 // configuration graph need to implement in order to build the variable // dependencies properly. type graphNodeConfig interface { - depgraph.Node + dag.Node // Variables returns the full list of variables that this node // 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 // for this node. This is used to modify the dependencies. The key of // this map should be the VarName() of graphNodeConfig. - depMap() map[string]depgraph.Node - setDepMap(map[string]depgraph.Node) + depMap() map[string]dag.Node + setDepMap(map[string]dag.Node) } // 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 // these features for free. type graphNodeConfigBasicDepMap struct { - DepMap map[string]depgraph.Node + DepMap map[string]dag.Node } -func (n *graphNodeConfigBasicDepMap) Deps() []depgraph.Node { - r := make([]depgraph.Node, 0, len(n.DepMap)) +func (n *graphNodeConfigBasicDepMap) Deps() []dag.Node { + r := make([]dag.Node, 0, len(n.DepMap)) for _, v := range n.DepMap { if v != nil { r = append(r, v) @@ -49,11 +49,11 @@ func (n *graphNodeConfigBasicDepMap) Deps() []depgraph.Node { return r } -func (n *graphNodeConfigBasicDepMap) depMap() map[string]depgraph.Node { +func (n *graphNodeConfigBasicDepMap) depMap() map[string]dag.Node { return n.DepMap } -func (n *graphNodeConfigBasicDepMap) setDepMap(m map[string]depgraph.Node) { +func (n *graphNodeConfigBasicDepMap) setDepMap(m map[string]dag.Node) { n.DepMap = m } diff --git a/terraform/graph_config_node_test.go b/terraform/graph_config_node_test.go index bcfd4539b..dc18d66aa 100644 --- a/terraform/graph_config_node_test.go +++ b/terraform/graph_config_node_test.go @@ -3,11 +3,11 @@ package terraform import ( "testing" - "github.com/hashicorp/terraform/depgraph2" + "github.com/hashicorp/terraform/dag" ) func TestGraphNodeConfigResource_impl(t *testing.T) { - var _ depgraph.Node = new(GraphNodeConfigResource) - var _ depgraph.NamedNode = new(GraphNodeConfigResource) + var _ dag.Node = new(GraphNodeConfigResource) + var _ dag.NamedNode = new(GraphNodeConfigResource) var _ graphNodeConfig = new(GraphNodeConfigResource) }