diff --git a/config/module/tree.go b/config/module/tree.go index 6e6d30e0a..e92361180 100644 --- a/config/module/tree.go +++ b/config/module/tree.go @@ -10,6 +10,9 @@ import ( "github.com/hashicorp/terraform/config" ) +// RootName is the name of the root tree. +const RootName = "root" + // Tree represents the module import tree of configurations. // // This Tree structure can be used to get (download) new modules, load @@ -100,7 +103,7 @@ func (t *Tree) Modules() []*Module { // tree and then the module name given for any children. func (t *Tree) Name() string { if t.name == "" { - return "" + return RootName } return t.name diff --git a/config/module/tree_test.go b/config/module/tree_test.go index 95c481dde..7ac574ec4 100644 --- a/config/module/tree_test.go +++ b/config/module/tree_test.go @@ -75,7 +75,7 @@ func TestTreeName(t *testing.T) { tree := NewTree("", testConfig(t, "basic")) actual := tree.Name() - if actual != "" { + if actual != RootName { t.Fatalf("bad: %#v", actual) } } @@ -150,6 +150,6 @@ func TestTreeValidate_notLoaded(t *testing.T) { const treeLoadStr = ` - +root foo `