mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-19 13:12:58 -06:00
8df065a2fe
This is a mostly mechanical refactor with a handful of changes which are necessary due to the semantic difference between earlyconfig and configs. When parsing root and descendant modules in the module installer, we now check the core version requirements inline. If the Terraform version is incompatible, we drop any other module loader diagnostics. This ensures that future language additions don't clutter the output and confuse the user. We also add two new checks during the module load process: * Don't try to load a module with a `nil` source address. This is a necessary change due to the move away from earlyconfig. * Don't try to load a module with a blank name (i.e. `module ""`). Because our module loading manifest uses the stringified module path as its map key, this causes a collision with the root module, and a later panic. This is the bug which triggered this refactor in the first place.
26 lines
753 B
Go
26 lines
753 B
Go
package terraform
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/internal/tfdiags"
|
|
|
|
"github.com/hashicorp/terraform/internal/configs"
|
|
)
|
|
|
|
// CheckCoreVersionRequirements visits each of the modules in the given
|
|
// configuration tree and verifies that any given Core version constraints
|
|
// match with the version of Terraform Core that is being used.
|
|
//
|
|
// The returned diagnostics will contain errors if any constraints do not match.
|
|
// The returned diagnostics might also return warnings, which should be
|
|
// displayed to the user.
|
|
func CheckCoreVersionRequirements(config *configs.Config) tfdiags.Diagnostics {
|
|
if config == nil {
|
|
return nil
|
|
}
|
|
|
|
var diags tfdiags.Diagnostics
|
|
diags = diags.Append(config.CheckCoreVersionRequirements())
|
|
|
|
return diags
|
|
}
|