tfvet

command module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 2 Imported by: 0

README

Terraform Vet (tfvet)

Terraform vet is a simplistic, pluggable terraform linter.

Go Report Card License

Click on image for demo

Features

  • Pluggable and configurable rules.
  • Write simple, testable rules in golang, using simple data structures.
  • Simple, intuitive command line interface.

Install

Download the binary:
  • Linux: wget https://github.com/clintjedwards/tfvet/releases/latest/download/tfvet
Go Install:
  1. git clone https://github.com/clintjedwards/tfvet && cd tfvet
  2. go install
Build manually:
  1. git clone https://github.com/clintjedwards/tfvet && cd tfvet
  2. go build -o <your_path_here>

How it works

Tfvet allows you to lint terraform files using pluggable rules written in golang. It's meant to offer a simple, configurable interface that makes it easy to write and retrieve rules for.

1) Add a ruleset

Rules are packages into "rulesets" which can be added via the command line.

$ tfvet ruleset add github.com/clintjedwards/tfvet-ruleset-example

Rulesets usually package one or more linting rules and can be added from a variety of sources. You create a local ruleset on your specific machine or download one from a remote source.

The example ruleset above contains a few rules that are used for testing.

2) Start linting files!

$ tfvet lint

By default tfvet looks into the local directory on run to find terraform files. This is easily changed by adding a path or multiple paths. The path argument allows for file globbing:

$ tfvet lint ./internal/testdata/*

How to create rules

Rules are grouped into packaging called rulesets. These rulesets can be added and removed from your local tfvet linter as you see fit.

Find how to create a new ruleset here.

You can find an example ruleset here.

Application structure

  • internal: All packages inside here are not meant to be consumed as a library.
    • cli: Main logic of the program; contains all logic that controls command line manipulation.
    • config: Controls application level environment variables.
    • plugin: Provides the go-plugin related structures that allow rules to act as plugins.
    • testdata: Contains artifacts used for testing.
    • utils: Common directory for piece of code used throughout.
  • sdk: The software development toolkit that assists with creating rulesets and rules.

Drawbacks

  • The lint rules are designed to only consume one file at a time, they cannot alert on project wide errors.

Author

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
cli
cli/appcfg
Package appcfg controls actions that can be performed around the app's configuration file and config directory.
Package appcfg controls actions that can be performed around the app's configuration file and config directory.
cli/models
Package models represents data structure which are shared between packages.
Package models represents data structure which are shared between packages.
plugin
Package plugin orchestrates the plugin relationship between rules and the tfvet process It uses hashicorp's go-plugin which implements a local client/server relationship with plugins and allows communication to the plugins over grpc.
Package plugin orchestrates the plugin relationship between rules and the tfvet process It uses hashicorp's go-plugin which implements a local client/server relationship with plugins and allows communication to the plugins over grpc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL