From ef0f0bc8085a11c1f4d45919d723e49d88256cde Mon Sep 17 00:00:00 2001 From: Kazuma Watanabe Date: Sat, 22 Apr 2023 13:17:35 +0000 Subject: [PATCH] Use NewRunner hook --- aws/ruleset.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/aws/ruleset.go b/aws/ruleset.go index 49589876..16d21af5 100644 --- a/aws/ruleset.go +++ b/aws/ruleset.go @@ -1,8 +1,6 @@ package aws import ( - "fmt" - "github.com/terraform-linters/tflint-plugin-sdk/hclext" "github.com/terraform-linters/tflint-plugin-sdk/tflint" ) @@ -43,17 +41,7 @@ func (r *RuleSet) ApplyConfig(body *hclext.BodyContent) error { return nil } -// Check runs inspections for each rule with the custom AWS runner. -func (r *RuleSet) Check(rr tflint.Runner) error { - runner, err := NewRunner(rr, r.config) - if err != nil { - return err - } - - for _, rule := range r.EnabledRules { - if err := rule.Check(runner); err != nil { - return fmt.Errorf("Failed to check `%s` rule: %s", rule.Name(), err) - } - } - return nil +// NewRunner injects a custom AWS runner +func (r *RuleSet) NewRunner(runner tflint.Runner) (tflint.Runner, error) { + return NewRunner(runner, r.config) }