github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/awsrules/models/aws_cloudwatch_event_target_invalid_input.go (about) 1 // This file generated by `tools/model-rule-gen/main.go`. DO NOT EDIT 2 3 package models 4 5 import ( 6 "log" 7 8 hcl "github.com/hashicorp/hcl/v2" 9 "github.com/wata727/tflint/tflint" 10 ) 11 12 // AwsCloudwatchEventTargetInvalidInputRule checks the pattern is valid 13 type AwsCloudwatchEventTargetInvalidInputRule struct { 14 resourceType string 15 attributeName string 16 max int 17 } 18 19 // NewAwsCloudwatchEventTargetInvalidInputRule returns new rule with default attributes 20 func NewAwsCloudwatchEventTargetInvalidInputRule() *AwsCloudwatchEventTargetInvalidInputRule { 21 return &AwsCloudwatchEventTargetInvalidInputRule{ 22 resourceType: "aws_cloudwatch_event_target", 23 attributeName: "input", 24 max: 8192, 25 } 26 } 27 28 // Name returns the rule name 29 func (r *AwsCloudwatchEventTargetInvalidInputRule) Name() string { 30 return "aws_cloudwatch_event_target_invalid_input" 31 } 32 33 // Enabled returns whether the rule is enabled by default 34 func (r *AwsCloudwatchEventTargetInvalidInputRule) Enabled() bool { 35 return true 36 } 37 38 // Severity returns the rule severity 39 func (r *AwsCloudwatchEventTargetInvalidInputRule) Severity() string { 40 return tflint.ERROR 41 } 42 43 // Link returns the rule reference link 44 func (r *AwsCloudwatchEventTargetInvalidInputRule) Link() string { 45 return "" 46 } 47 48 // Check checks the pattern is valid 49 func (r *AwsCloudwatchEventTargetInvalidInputRule) Check(runner *tflint.Runner) error { 50 log.Printf("[TRACE] Check `%s` rule for `%s` runner", r.Name(), runner.TFConfigPath()) 51 52 return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { 53 var val string 54 err := runner.EvaluateExpr(attribute.Expr, &val) 55 56 return runner.EnsureNoError(err, func() error { 57 if len(val) > r.max { 58 runner.EmitIssue( 59 r, 60 "input must be 8192 characters or less", 61 attribute.Expr.Range(), 62 ) 63 } 64 return nil 65 }) 66 }) 67 }