configs: Fail early for invalid resource provider
If a resource's "provider" reference is invalid and cannot be parsed, we should not store the reference as part of a `ProviderConfigRef`. Doing so creates an invalid data structure, which prevents us from using `MustParseProviderPart` with the name in later steps. The invalid test files added in this commit will cause a panic without the code change.
This commit is contained in:
parent
4459e6ea3a
commit
5e3d2dbdfa
|
@ -422,6 +422,9 @@ func decodeProviderConfigRef(expr hcl.Expression, argName string) (*ProviderConf
|
|||
name := traversal.RootName()
|
||||
nameDiags := checkProviderNameNormalized(name, traversal[0].SourceRange())
|
||||
diags = append(diags, nameDiags...)
|
||||
if diags.HasErrors() {
|
||||
return nil, diags
|
||||
}
|
||||
|
||||
ret := &ProviderConfigRef{
|
||||
Name: name,
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
data "test_resource" "t" {
|
||||
provider = my_test
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
resource "test_resource" "t" {
|
||||
provider = my_test
|
||||
}
|
Loading…
Reference in New Issue