A linting tool for Terraform Provider code.
Release binaries are available in the Releases section.
To instead use Go to install into your $GOBIN
directory (e.g. $GOPATH/bin
):
$ go get github.com/bflad/tfproviderlint/cmd/tfproviderlint
$ docker pull bflad/tfproviderlint
$ brew install bflad/tap/tfproviderlint
Additional information about usage and configuration options can be found by passing the help
argument:
$ tfproviderlint help
Change into the directory of the Terraform Provider code and run:
$ tfproviderlint ./...
It is also possible to run via go vet
:
$ go vet -vettool $(which tfproviderlint) ./...
Change into the directory of the Terraform Provider code and run:
$ docker run -v $(pwd):/src bflad/tfproviderlint ./...
A GitHub Action is available: tfproviderlint-github-action
For additional information about each check, you can run tfproviderlint help NAME
.
Check | Description | Type |
---|---|---|
AT001 | check for TestCase missing CheckDestroy |
AST |
AT002 | check for acceptance test function names including the word import | AST |
AT003 | check for acceptance test function names missing an underscore | AST |
AT004 | check for TestStep Config containing provider configuration |
AST |
Check | Description | Type |
---|---|---|
R001 | check for ResourceData.Set() calls using complex key argument |
AST |
R002 | check for ResourceData.Set() calls using * dereferences |
AST |
R003 | check for Resource having Exists functions |
AST |
R004 | check for ResourceData.Set() calls using incompatible value types |
AST |
Check | Description | Type |
---|---|---|
S001 | check for Schema of TypeList or TypeSet missing Elem |
AST |
S002 | check for Schema with both Required and Optional enabled |
AST |
S003 | check for Schema with both Required and Computed enabled |
AST |
S004 | check for Schema with both Required and Default configured |
AST |
S005 | check for Schema with both Computed and Default configured |
AST |
S006 | check for Schema of TypeMap missing Elem |
AST |
This project is built on the go/analysis
framework and uses Go Modules for dependency management.
Helpful tooling for development:
astdump
: a tool for displaying the AST form of Go filessadump
: a tool for displaying and interpreting the SSA form of Go programs
- Create new analyzer in
passes/
- Add new analyzer in
cmd/tfproviderlint/tfproviderlint.go
- Since the
analysistest
package does not support Go Modules currently, each analyzer that implements testing must add a symlink to the top levelvendor
directory in thetestdata/src
directory. e.g.ln -s ../../../../vendor passes/NAME/testdata/src/vendor
$ go get URL
$ go mod tidy
$ go mod vendor
$ go test ./...
$ go install ./cmd/tfproviderlint