Merge pull request #30095 from hashicorp/jbardin/invalid-provider-name

skip provider resolution when there are errors
This commit is contained in:
James Bardin 2021-12-21 16:58:48 -05:00 committed by GitHub
commit a72d2d408d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 3 deletions

View File

@ -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)...)

View File

@ -0,0 +1 @@
main.tf:1,1-20: Invalid provider local name; crash_es is an invalid provider local name

View File

@ -0,0 +1,3 @@
module "mod" {
source = "./mod"
}

View File

@ -0,0 +1,2 @@
provider "crash_es" {
}

View File

@ -0,0 +1 @@
Empty provider configuration blocks are not required