github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/terraformrules/terraform_documented_outputs.go (about)

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