terraform-linters / tflint

A Pluggable Terraform Linter
Mozilla Public License 2.0
4.86k stars 354 forks source link

Clarify tflint plugin errors? #879

Closed MattMencel closed 4 years ago

MattMencel commented 4 years ago

Is it possible for this error to be clarified? It took me awhile before I finally figured out it was the azure plugin for tflint I needed to update. Probably me just being dumb, but if it said "Incompatible API version with tflint azure plugin." I might have picked up on it quicker. :)

Also... any way to keep the tflint plugins updated automatically?

> tflint .
Failed to initialize plugins. An error occurred:

Error: Incompatible API version with plugin. Plugin version: 2, Client versions: [4]

If this should be moved to the main tflint repo let me know.

wata727 commented 4 years ago

Thank you for sharing your use case. It makes sense.

Is it possible for this error to be clarified?

Probably. The error message is returned from go-plugin, but we can inject any messages before printing the original message like the following:

Failed to initialize plugins. An error occurred:

Error: Incompatible API version with TFLint and plugin "azure". Please upgrade (plugin/TFLint) version.

any way to keep the tflint plugins updated automatically?

Do you imagine something similar to terraform init?

MattMencel commented 4 years ago

I run tflint from pre-commit-terraform, along with several other pre-commit modules/plugins. I'm not sure where the plugin upgrade would happen in that case. Perhaps simply adding a link in that error message to a "howto update the plugin" document would be enough?

wata727 commented 4 years ago

Umm, in my opinion, I would like to avoid including that information in the error message. I think it is a little redundant... I'm not familiar with pre-commit-terraform, so I'm not sure, but maybe it's a problem that pre-commit-terraform should solve.

bendrucker commented 4 years ago

Agreed that linking to instructions is not really a viable fix, considering plugin installation is manual. I think specific messaging that tells you which component needs upgrading (TFLint or the plugin) would be nice. "Plugin" and "client" may not be obvious to users unfamiliar with the plugin mechanics of Terraform.

Beyond that, only dynamic dependency installs (a la terraform init) really make this better. I do think the plugin mechanics are important and improving them is key to making TFLint more like Terraform—minimal core, everything's a plugin. An important step there would be shipping TFLint with zero rules and migrating existing users to tflint-ruleset-terraform and tflint-rulset-aws. Doing that without major user inconvenience will probably mean enhancing the plugin system, possibly including some cloud indexing of "official" rulesets a la Terraform.

wata727 commented 4 years ago

Beyond that, only dynamic dependency installs (a la terraform init) really make this better

Totally agreed. In order for the plugin system to become production-ready, such a mechanism would be needed. There are many things to consider, such as what registry to distribute plugins in and how to prevent malicious plugins from executing.