mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #28072 from hashicorp/jbardin/provider-meta-interpolation
validate provider_meta contains no interpolations
This commit is contained in:
commit
0750a16cce
@ -13,8 +13,20 @@ type ProviderMeta struct {
|
||||
}
|
||||
|
||||
func decodeProviderMetaBlock(block *hcl.Block) (*ProviderMeta, hcl.Diagnostics) {
|
||||
// provider_meta must be a static map. We can verify this by attempting to
|
||||
// evaluate the values.
|
||||
attrs, diags := block.Body.JustAttributes()
|
||||
if diags.HasErrors() {
|
||||
return nil, diags
|
||||
}
|
||||
|
||||
for _, attr := range attrs {
|
||||
_, d := attr.Expr.Value(nil)
|
||||
diags = append(diags, d...)
|
||||
}
|
||||
|
||||
// verify that the local name is already localized or produce an error.
|
||||
diags := checkProviderNameNormalized(block.Labels[0], block.DefRange)
|
||||
diags = append(diags, checkProviderNameNormalized(block.Labels[0], block.DefRange)...)
|
||||
|
||||
return &ProviderMeta{
|
||||
Provider: block.Labels[0],
|
||||
|
10
configs/testdata/invalid-modules/provider-meta/invalid-interpolation.tf
vendored
Normal file
10
configs/testdata/invalid-modules/provider-meta/invalid-interpolation.tf
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
terraform {
|
||||
provider_meta "my-provider" {
|
||||
hello = var.name
|
||||
}
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
type = string
|
||||
}
|
||||
|
5
configs/testdata/valid-modules/provider-meta/main.tf
vendored
Normal file
5
configs/testdata/valid-modules/provider-meta/main.tf
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
terraform {
|
||||
provider_meta "my-provider" {
|
||||
hello = "test-module"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user