diff --git a/config/config.go b/config/config.go index c074f0de2..87145828a 100644 --- a/config/config.go +++ b/config/config.go @@ -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, diff --git a/config/config_test.go b/config/config_test.go index 1c7463b4d..7a86fd862 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -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") }