github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/terraformrules/terraform_dash_in_resource_name.go (about) 1 package terraformrules 2 3 import ( 4 "fmt" 5 "log" 6 "strings" 7 8 "github.com/wata727/tflint/tflint" 9 ) 10 11 // TerraformDashInResourceNameRule checks whether resources have any dashes in the name 12 type TerraformDashInResourceNameRule struct{} 13 14 // NewTerraformDashInResourceNameRule returns a new rule 15 func NewTerraformDashInResourceNameRule() *TerraformDashInResourceNameRule { 16 return &TerraformDashInResourceNameRule{} 17 } 18 19 // Name returns the rule name 20 func (r *TerraformDashInResourceNameRule) Name() string { 21 return "terraform_dash_in_resource_name" 22 } 23 24 // Enabled returns whether the rule is enabled by default 25 func (r *TerraformDashInResourceNameRule) Enabled() bool { 26 return false 27 } 28 29 // Severity returns the rule severity 30 func (r *TerraformDashInResourceNameRule) Severity() string { 31 return tflint.NOTICE 32 } 33 34 // Link returns the rule reference link 35 func (r *TerraformDashInResourceNameRule) Link() string { 36 return tflint.ReferenceLink(r.Name()) 37 } 38 39 // Check checks whether resources have any dashes in the name 40 func (r *TerraformDashInResourceNameRule) Check(runner *tflint.Runner) error { 41 log.Printf("[TRACE] Check `%s` rule for `%s` runner", r.Name(), runner.TFConfigPath()) 42 43 for _, resource := range runner.TFConfig.Module.ManagedResources { 44 if strings.Contains(resource.Name, "-") { 45 runner.EmitIssue( 46 r, 47 fmt.Sprintf("`%s` resource name has a dash", resource.Name), 48 resource.DeclRange, 49 ) 50 } 51 } 52 53 return nil 54 }