in outputs/requried_output.go [66:97]
func (vcr *RequiredOutputRule) Check(r tflint.Runner) error {
path, err := r.GetModulePath()
if err != nil {
return err
}
if !path.IsRoot() {
// This rule does not evaluate child modules.
return nil
}
// Define the schema that we want to pull out of the module content.
body, err := r.GetModuleContent(
outputBodySchema,
&tflint.GetModuleContentOption{ExpandMode: tflint.ExpandModeNone})
if err != nil {
return err
}
// Iterate over the outputs and check for the name we are interested in.
for _, b := range body.Blocks {
if b.Labels[0] == vcr.outputName {
return nil
}
}
return r.EmitIssue(
vcr,
fmt.Sprintf("module owners MUST output the `%s` in their modules", vcr.outputName),
hcl.Range{
Filename: "outputs.tf",
},
)
}