mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 17:01:04 -06:00
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:
parent
4ab8973520
commit
ccb3a7c584
@ -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 {
|
||||
|
@ -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.
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user