config: rename ResourceGraph to Graph

This commit is contained in:
Mitchell Hashimoto 2014-06-05 12:55:21 -07:00
parent 867f6b3691
commit 82d527f798
2 changed files with 9 additions and 9 deletions

View File

@ -9,9 +9,9 @@ import (
"github.com/hashicorp/terraform/depgraph"
)
// ResourceGraphRoot is the name of the resource graph root that should be
// GraphRoot is the name of the resource graph root that should be
// ignored since it doesn't map to an exact resource.
const ResourceGraphRoot = "root"
const GraphRoot = "root"
// Config is the configuration that comes from loading a collection
// of Terraform templates.
@ -122,13 +122,13 @@ func (r *Resource) ReplaceVariables(vs map[string]string) *Resource {
return &result
}
// ResourceGraph returns a dependency graph of the resources from this
// Graph returns a dependency graph of the resources from this
// Terraform configuration.
//
// The graph can contain both *Resource and *ProviderConfig. When consuming
// the graph, you'll have to use type inference to determine what it is
// and the proper behavior.
func (c *Config) ResourceGraph() *depgraph.Graph {
func (c *Config) Graph() *depgraph.Graph {
// This tracks all the resource nouns
nouns := make(map[string]*depgraph.Noun)
for _, r := range c.Resources {
@ -207,7 +207,7 @@ func (c *Config) ResourceGraph() *depgraph.Graph {
}
// Create a root that just depends on everything else finishing.
root := &depgraph.Noun{Name: ResourceGraphRoot}
root := &depgraph.Noun{Name: GraphRoot}
for _, n := range nounsList {
root.Deps = append(root.Deps, &depgraph.Dependency{
Name: n.Name,

View File

@ -10,13 +10,13 @@ import (
// This is the directory where our test fixtures are.
const fixtureDir = "./test-fixtures"
func TestConfigResourceGraph(t *testing.T) {
func TestConfigGraph(t *testing.T) {
c, err := Load(filepath.Join(fixtureDir, "resource_graph.tf"))
if err != nil {
t.Fatalf("err: %s", err)
}
graph := c.ResourceGraph()
graph := c.Graph()
if err := graph.Validate(); err != nil {
t.Fatalf("err: %s", err)
}
@ -29,13 +29,13 @@ func TestConfigResourceGraph(t *testing.T) {
}
}
func TestConfigResourceGraph_cycle(t *testing.T) {
func TestConfigGraph_cycle(t *testing.T) {
c, err := Load(filepath.Join(fixtureDir, "resource_graph_cycle.tf"))
if err != nil {
t.Fatalf("err: %s", err)
}
graph := c.ResourceGraph()
graph := c.Graph()
if err := graph.Validate(); err == nil {
t.Fatal("graph should be invalid")
}