Skip to content

Commit

Permalink
fix(terraform_required_version_range): skip missing
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Aug 14, 2024
1 parent f903e4f commit eb20ec6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tflint-ruleset-blueprint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func main() {
plugin.Serve(&plugin.ServeOpts{
RuleSet: &tflint.BuiltinRuleSet{
Name: "blueprint",
Version: "0.2.2",
Version: "0.2.3",
Rules: []tflint.Rule{
rules.NewTerraformDocSamplesRestrictedBlocks(),
rules.NewTerraformDocSamplesRestrictedResources(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,14 @@ func (r *TerraformRequiredVersionRange) Check(runner tflint.Runner) error {
}

for _, block := range content.Blocks {
requiredVersion, exists := block.Body.Attributes["required_version"]
if !exists {
logger.Info(fmt.Sprintf("required_version does not exist for %s", block.Labels[0]))
continue
}

var raw_terraform_required_version string
diags := gohcl.DecodeExpression(block.Body.Attributes["required_version"].Expr, nil, &raw_terraform_required_version)
diags := gohcl.DecodeExpression(requiredVersion.Expr, nil, &raw_terraform_required_version)
if diags.HasErrors() {
return fmt.Errorf("failed to decode terraform required_version %q: %v", block.Labels[0], diags.Error())
}
Expand Down

0 comments on commit eb20ec6

Please sign in to comment.