Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental plugin support #500

Merged
merged 7 commits into from
Nov 9, 2019
Merged

Experimental plugin support #500

merged 7 commits into from
Nov 9, 2019

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Oct 22, 2019

Fixes #499
Closes #255

This pull request introduces an experimental plugin system. TFLint adopts https://golang.org/pkg/plugin to achieve the goal.

Plugins are placed in the ~/.tflint.d/plugins directory with the naming convention tflint-ruleset-<NAME>.so. You can explicitly enable the plugin by .tflint.hcl as follows:

plugin "NAME" {
    enabled = true
}

That's all. Now you can freely add custom rules to TFLint!

Plugins are provided as a single *.so file and can be easily built with go build --buildmode=plugin main.go. You can see an example: https://github.com/terraform-linters/tflint-ruleset-template

The plugin must satisfy the following constraints:

  • Name function is implemented under the main package.
    • It should return the plugin name as a string.
  • Version function is implemented under the main package.
    • It should return the plugin version as a string.
  • NewRules function is implemented under the main package.
    • It should return a list of rules that implement plugin.Rule interface.
  • It is built using the same TFLint version.

Note the plugin package is only supported on Linux and macOS. Therefore, this plugin system does not work on Windows.

@wata727 wata727 force-pushed the tflint_go_plugin branch 3 times, most recently from eb05791 to fbe904d Compare November 4, 2019 06:06
@wata727 wata727 marked this pull request as ready for review November 4, 2019 09:11
@wata727 wata727 force-pushed the tflint_go_plugin branch 2 times, most recently from 637e828 to 81ca23a Compare November 4, 2019 16:06
@wata727 wata727 changed the title Experimental plugin support (pkg/plugin version) Experimental plugin support Nov 9, 2019
@wata727 wata727 merged commit b8dacfb into master Nov 9, 2019
@wata727 wata727 deleted the tflint_go_plugin branch November 9, 2019 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Plugin system
1 participant