func checkDefaultValue()

in interfaces/interface_variable.go [201:224]


func checkDefaultValue(vcr *InterfaceVarCheckRule, r tflint.Runner, b *hclext.Block, defaultAttr *hclext.Attribute) func() (bool, error) {
	return func() (bool, error) {
		// Check if the default value is correct.
		if !vcr.Default.IsKnown() {
			if defaultAttr != nil {
				return true, r.EmitIssue(
					vcr,
					fmt.Sprintf("default value should not be set, see: %s", vcr.Link()),
					defaultAttr.Range,
				)
			}
			return true, nil
		}
		defaultVal, _ := defaultAttr.Expr.Value(nil)
		if !check.EqualCtyValue(defaultVal, vcr.Default) {
			return true, r.EmitIssue(
				vcr,
				fmt.Sprintf("default value is not correct, see: %s", vcr.Link()),
				b.DefRange,
			)
		}
		return true, nil
	}
}