dag: rename to this
This commit is contained in:
parent
012dcca7d5
commit
87f4c3aae1
|
@ -1,4 +1,4 @@
|
|||
package depgraph
|
||||
package dag
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue