configs: fix panic when the value is missing from version attribute in a provider block

This commit is contained in:
Kristin Laemmert 2019-06-21 14:30:17 -04:00 committed by GitHub
parent a0f06826ab
commit 2a457115a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,3 @@
provider "template" {
version =
}

View File

@ -45,6 +45,13 @@ func decodeVersionConstraint(attr *hcl.Attribute) (VersionConstraint, hcl.Diagno
return ret, diags return ret, diags
} }
if !val.IsWhollyKnown() {
// If there is a syntax error, HCL sets the value of the given attribute
// to cty.DynamicVal. A diagnostic for the syntax error will already
// bubble up, so we will move forward gracefully here.
return ret, diags
}
constraintStr := val.AsString() constraintStr := val.AsString()
constraints, err := version.NewConstraint(constraintStr) constraints, err := version.NewConstraint(constraintStr)
if err != nil { if err != nil {