mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-17 12:12:59 -06:00
skip provider resolution when there are errors
If there are errors loading the configuration, don't try to resolve the provider names, as those names may not even be valid.
This commit is contained in:
parent
16800d1305
commit
0771a214d8
@ -23,9 +23,13 @@ func BuildConfig(root *Module, walker ModuleWalker) (*Config, hcl.Diagnostics) {
|
||||
cfg.Root = cfg // Root module is self-referential.
|
||||
cfg.Children, diags = buildChildModules(cfg, walker)
|
||||
|
||||
// Now that the config is built, we can connect the provider names to all
|
||||
// the known types for validation.
|
||||
cfg.resolveProviderTypes()
|
||||
// Skip provider resolution if there are any errors, since the provider
|
||||
// configurations themselves may not be valid.
|
||||
if !diags.HasErrors() {
|
||||
// Now that the config is built, we can connect the provider names to all
|
||||
// the known types for validation.
|
||||
cfg.resolveProviderTypes()
|
||||
}
|
||||
|
||||
diags = append(diags, validateProviderConfigs(nil, cfg, false)...)
|
||||
|
||||
|
1
internal/configs/testdata/config-diagnostics/invalid-provider/errors
vendored
Normal file
1
internal/configs/testdata/config-diagnostics/invalid-provider/errors
vendored
Normal file
@ -0,0 +1 @@
|
||||
main.tf:1,1-20: Invalid provider local name; crash_es is an invalid provider local name
|
3
internal/configs/testdata/config-diagnostics/invalid-provider/main.tf
vendored
Normal file
3
internal/configs/testdata/config-diagnostics/invalid-provider/main.tf
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module "mod" {
|
||||
source = "./mod"
|
||||
}
|
2
internal/configs/testdata/config-diagnostics/invalid-provider/mod/main.tf
vendored
Normal file
2
internal/configs/testdata/config-diagnostics/invalid-provider/mod/main.tf
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
provider "crash_es" {
|
||||
}
|
1
internal/configs/testdata/config-diagnostics/invalid-provider/warnings
vendored
Normal file
1
internal/configs/testdata/config-diagnostics/invalid-provider/warnings
vendored
Normal file
@ -0,0 +1 @@
|
||||
Empty provider configuration blocks are not required
|
Loading…
Reference in New Issue
Block a user