tflint-plugin-sdk

module
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MPL-2.0

README

TFLint plugin SDK

Build Status GitHub release go.dev reference

TFLint plugin SDK for building custom rules.

NOTE: This plugin system is experimental. This means that API compatibility is frequently broken.

Requirements

  • TFLint v0.42+
  • Go v1.22

Usage

Please refer to tflint-ruleset-template for an example plugin implementation using this SDK.

For more details on the API, see https://pkg.go.dev/github.com/terraform-linters/tflint-plugin-sdk.

Developing

The proto compiler is required when updating .proto files. The protoc and protoc-gen-go can be installed using aqua.

$ make prepare
curl -sSfL https://raw.githubusercontent.com/aquaproj/aqua-installer/v2.1.1/aqua-installer | bash
===> Installing aqua v2.2.3 for bootstraping...

...

aqua version 2.3.7 (c07105b10ab825e7f309d2eb83278a0422a2b24f)

Add ${AQUA_ROOT_DIR}/bin to the environment variable PATH.
export PATH="${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin:$PATH"
$ export PATH="${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin:$PATH"
$ aqua install
$ make proto

Architecture

This plugin system uses go-plugin. TFLint launch plugins as sub-processes and communicates with plugins over gRPC. A plugin acts as a server, while TFLint acts as a client that sends inspection requests to the plugin.

On the other hand, the plugin sends various requests to a server (TFLint) to get detailed runtime contexts (e.g. variables and expressions). This means that TFLint and plugins can act as both a server and a client.

This SDK provides client, server and Protocol Buffers for these bi-directional communications. See Architecture for more details.

Directories

Path Synopsis
Package hclext is an extension of package hcl for TFLint.
Package hclext is an extension of package hcl for TFLint.
Package helper contains implementations for plugin testing.
Package helper contains implementations for plugin testing.
Package logger provides a global logger interface for logging from plugins.
Package logger provides a global logger interface for logging from plugins.
Package plugin contains the implementations needed to make the built binary act as a plugin.
Package plugin contains the implementations needed to make the built binary act as a plugin.
host2plugin
Package host2plugin exposes a gRPC client for use on a host (TFLint).
Package host2plugin exposes a gRPC client for use on a host (TFLint).
internal/fromproto
Package fromproto contains an implementation to decode a structure generated from *.proto into a real Go structure.
Package fromproto contains an implementation to decode a structure generated from *.proto into a real Go structure.
internal/host2plugin
Package host2plugin contains a gRPC server (plugin) and client (host).
Package host2plugin contains a gRPC server (plugin) and client (host).
internal/interceptor
Package interceptor contains gRPC interceptors.
Package interceptor contains gRPC interceptors.
internal/plugin2host
Package plugin2host contains a gRPC server (host) and client (plugin).
Package plugin2host contains a gRPC server (host) and client (plugin).
internal/proto
Package proto contains generated protocol buffers structures.
Package proto contains generated protocol buffers structures.
internal/toproto
Package toproto contains an implementation to encode a Go structure into a structure generated from *.proto.
Package toproto contains an implementation to encode a Go structure into a structure generated from *.proto.
plugin2host
Package plugin2host exposes a gRPC server for use on a host (TFLint).
Package plugin2host exposes a gRPC server for use on a host (TFLint).
addrs
Package addrs is a fork of Terraform's internal/addrs package.
Package addrs is a fork of Terraform's internal/addrs package.
lang
Package lang is a fork of Terraform's internal/lang package.
Package lang is a fork of Terraform's internal/lang package.
Package tflint contains implementations and interfaces for plugin developers.
Package tflint contains implementations and interfaces for plugin developers.

Jump to

Keyboard shortcuts

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