diff --git a/tflint-ruleset-blueprint/main.go b/tflint-ruleset-blueprint/main.go index 86350a01008..79c0201ced4 100644 --- a/tflint-ruleset-blueprint/main.go +++ b/tflint-ruleset-blueprint/main.go @@ -10,7 +10,7 @@ func main() { plugin.Serve(&plugin.ServeOpts{ RuleSet: &tflint.BuiltinRuleSet{ Name: "blueprint", - Version: "0.2.3", + Version: "0.2.4", Rules: []tflint.Rule{ rules.NewTerraformDocSamplesRestrictedBlocks(), rules.NewTerraformDocSamplesRestrictedResources(), diff --git a/tflint-ruleset-blueprint/rules/terraform_required_version_range.go b/tflint-ruleset-blueprint/rules/terraform_required_version_range.go index f15bd36c5f9..066fe15f7e7 100644 --- a/tflint-ruleset-blueprint/rules/terraform_required_version_range.go +++ b/tflint-ruleset-blueprint/rules/terraform_required_version_range.go @@ -147,14 +147,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])) + logger.Info(fmt.Sprintf("terraform block does not contain required_version: %s", block.DefRange)) continue } var raw_terraform_required_version string 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()) + return fmt.Errorf("failed to decode terraform block required_version: %v", diags.Error()) } constraints, err := version.NewConstraint(raw_terraform_required_version) @@ -162,7 +162,6 @@ func (r *TerraformRequiredVersionRange) Check(runner tflint.Runner) error { return err } - //TODO: add option for repository exemptions if !((constraints.Check(minimum_required_version) || constraints.Check(maximum_required_version)) && !constraints.Check(below_required_version)) { //TODO: use EmitIssueWithFix() err := runner.EmitIssue(r, fmt.Sprintf("required_version is not inclusive of the the minimum %q and maximum %q terraform required_version: %q", minVersion, maxVersion, constraints.String()), block.DefRange) @@ -170,7 +169,6 @@ func (r *TerraformRequiredVersionRange) Check(runner tflint.Runner) error { return err } } - } return nil diff --git a/tflint-ruleset-blueprint/rules/testdata/terraform_required_version_range/multiple-valid-config/main.tf b/tflint-ruleset-blueprint/rules/testdata/terraform_required_version_range/multiple-valid-config/main.tf index d1ec99d54d7..39548f0e887 100644 --- a/tflint-ruleset-blueprint/rules/testdata/terraform_required_version_range/multiple-valid-config/main.tf +++ b/tflint-ruleset-blueprint/rules/testdata/terraform_required_version_range/multiple-valid-config/main.tf @@ -13,3 +13,13 @@ terraform { terraform { required_version = "~>1.9" } + +terraform { + backend "gcs" { + bucket = "UPDATE_ME" + prefix = "UPDATE_ME" + } +} + +terraform { +}