core: expose terraform.ModuleTreeDependencies as a public function

This is a generally-useful utility for computing dependency trees, so no
reason to restrict it to just the terraform package.
This commit is contained in:
Martin Atkins 2017-04-25 16:49:49 -07:00
parent 4ab8973520
commit ccb3a7c584
3 changed files with 4 additions and 4 deletions

View File

@ -178,7 +178,7 @@ func NewContext(opts *ContextOpts) (*Context, error) {
var providers map[string]ResourceProviderFactory
if opts.ProviderResolver != nil {
var err error
deps := moduleTreeDependencies(opts.Module, state)
deps := ModuleTreeDependencies(opts.Module, state)
reqd := deps.AllPluginRequirements()
providers, err = resourceProviderFactories(opts.ProviderResolver, reqd)
if err != nil {

View File

@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform/plugin/discovery"
)
// moduleTreeDependencies returns the dependencies of the tree of modules
// ModuleTreeDependencies returns the dependencies of the tree of modules
// described by the given configuration tree and state.
//
// Both configuration and state are required because there can be resources
@ -16,7 +16,7 @@ import (
// This function will panic if any invalid version constraint strings are
// present in the configuration. This is guaranteed not to happen for any
// configuration that has passed a call to Config.Validate().
func moduleTreeDependencies(root *module.Tree, state *State) *moduledeps.Module {
func ModuleTreeDependencies(root *module.Tree, state *State) *moduledeps.Module {
// First we walk the configuration tree to build the overall structure
// and capture the explicit/implicit/inherited provider dependencies.

View File

@ -248,7 +248,7 @@ func TestModuleTreeDependencies(t *testing.T) {
root = testModule(t, test.ConfigDir)
}
got := moduleTreeDependencies(root, test.State)
got := ModuleTreeDependencies(root, test.State)
if !got.Equal(test.Want) {
t.Errorf(
"wrong dependency tree\ngot: %s\nwant: %s",