-
Notifications
You must be signed in to change notification settings - Fork 348
/
terraform_documented_variables.go
53 lines (42 loc) · 1.36 KB
/
terraform_documented_variables.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package terraformrules
import (
"fmt"
"log"
"github.com/wata727/tflint/tflint"
)
// TerraformDocumentedVariablesRule checks whether variables have descriptions
type TerraformDocumentedVariablesRule struct{}
// NewTerraformDocumentedVariablesRule returns a new rule
func NewTerraformDocumentedVariablesRule() *TerraformDocumentedVariablesRule {
return &TerraformDocumentedVariablesRule{}
}
// Name returns the rule name
func (r *TerraformDocumentedVariablesRule) Name() string {
return "terraform_documented_variables"
}
// Enabled returns whether the rule is enabled by default
func (r *TerraformDocumentedVariablesRule) Enabled() bool {
return false
}
// Severity returns the rule severity
func (r *TerraformDocumentedVariablesRule) Severity() string {
return tflint.NOTICE
}
// Link returns the rule reference link
func (r *TerraformDocumentedVariablesRule) Link() string {
return tflint.ReferenceLink(r.Name())
}
// Check checks whether variables have descriptions
func (r *TerraformDocumentedVariablesRule) Check(runner *tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule for `%s` runner", r.Name(), runner.TFConfigPath())
for _, variable := range runner.TFConfig.Module.Variables {
if variable.Description == "" {
runner.EmitIssue(
r,
fmt.Sprintf("`%s` variable has no description", variable.Name),
variable.DeclRange,
)
}
}
return nil
}