tflint icon indicating copy to clipboard operation
tflint copied to clipboard

feat: support custom messages when failing tflint checks

Open nitrocode opened this issue 5 years ago • 5 comments

Would be nice to be able to define custom messages in every rule to either overwrite or append tflint's default message

nitrocode avatar May 21 '20 22:05 nitrocode

Since messages are assembled in code, just allowing a static replacement seems a bit confusing. Can you provide a real world example of how you'd use this?

bendrucker avatar May 21 '20 22:05 bendrucker

rule "aws_resource_missing_tags" {
  enabled = true
  tags    = ["Foo", "Bar"]
  exclude = ["aws_autoscaling_group"] # (Optional) Exclude some resource types from tag checks
  msg     = "bro bro bro you're missing some really important tags. see this confluence page for our mandatory tags page and why each tag is useful. also see this link for our custom terraform module that implements this to make life easier."
}

nitrocode avatar May 21 '20 22:05 nitrocode

Hmm, how about a custom URL that replaces the self-link to the TFLint docs? That way if you have custom rule configuration you can link to a custom document that describes how to fix the issue.

bendrucker avatar May 21 '20 23:05 bendrucker

¯_(ツ)_/¯

That would be more helpful and customizable than the current implementation. I'd still want to append the output at the very least. Like the example above, I'd want to share multiple links.

nitrocode avatar May 21 '20 23:05 nitrocode

Sounds good, an optional message that is printed after \n\n and the current text seems ok. Not of interest to me personally but happy to review a PR.

bendrucker avatar May 21 '20 23:05 bendrucker

Will share my thoughts at the moment.

I believe that in many cases this is the case where you want to apply the policy. So instead of supporting custom messages, I think it should be better to make defining policies easy. This is tracked by #1358.

However, for some rules, it may be useful to be able to set custom messages. In that case, you can address it by changing the rule implementation. There are currently no plans to provide this as a feature of TFLint CLI.

Closing this issue based on the above. If you want to discuss more, please open a new discussion instead of an issue. Thanks.

wata727 avatar Dec 28 '22 16:12 wata727