plugin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package plugin provides plugin discovery and runner implementation for tfbreak. Types and interfaces are imported from github.com/jokarl/tfbreak-plugin-sdk.

Index

Constants

View Source
const (
	// PluginPrefix is the naming convention for tfbreak plugins.
	PluginPrefix = "tfbreak-ruleset-"

	// PluginDirEnv is the environment variable for plugin directory.
	PluginDirEnv = "TFBREAK_PLUGIN_DIR"

	// LocalPluginDir is the local plugin directory relative to cwd.
	LocalPluginDir = ".tfbreak.d/plugins"

	// HomePluginDir is the home directory plugin path.
	HomePluginDir = ".tfbreak.d/plugins"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Issue

type Issue struct {
	// Rule is the rule that emitted the issue.
	Rule tflint.Rule
	// Message is the issue message.
	Message string
	// Range is the source location of the issue.
	Range hcl.Range
}

Issue represents a finding emitted by a plugin rule.

type Issues

type Issues []Issue

Issues is a slice of Issue for convenience.

type PluginInfo

type PluginInfo struct {
	// Name is the plugin name without prefix (e.g., "azurerm").
	Name string
	// Path is the full path to the plugin binary.
	Path string
	// Enabled indicates whether the plugin is enabled in config.
	Enabled bool
}

PluginInfo contains metadata about a discovered plugin.

func Discover

func Discover(cfg *config.Config) ([]PluginInfo, error)

Discover finds plugins from configured paths. Priority: config.PluginDir > TFBREAK_PLUGIN_DIR > ./.tfbreak.d/plugins > ~/.tfbreak.d/plugins

func GetEnabledPlugins

func GetEnabledPlugins(plugins []PluginInfo) []PluginInfo

GetEnabledPlugins returns only enabled plugins from the discovered list.

type Runner

type Runner struct {

	// Issues contains all issues emitted during rule execution.
	Issues Issues
	// contains filtered or unexported fields
}

Runner implements tflint.Runner for providing config access to plugins. This is the host-side implementation that provides old/new configurations to plugin rules during execution.

func NewRunner

func NewRunner(oldFiles, newFiles map[string]*hcl.File) *Runner

NewRunner creates a new Runner with the provided old and new HCL files.

func NewRunnerFromContent

func NewRunnerFromContent(oldContent, newContent map[string]string) (*Runner, error)

NewRunnerFromContent creates a Runner by parsing HCL content from string maps. This is useful for testing or when files are provided as strings.

func (*Runner) DecodeRuleConfig

func (r *Runner) DecodeRuleConfig(_ string, _ any) error

DecodeRuleConfig decodes rule-specific configuration. This is a stub implementation that returns nil (no config). Full implementation will be added when gRPC communication is implemented.

func (*Runner) EmitIssue

func (r *Runner) EmitIssue(rule tflint.Rule, message string, issueRange hcl.Range) error

EmitIssue records an issue from a plugin rule.

func (*Runner) GetNewModuleContent

func (r *Runner) GetNewModuleContent(schema *hclext.BodySchema, _ *tflint.GetModuleContentOption) (*hclext.BodyContent, error)

GetNewModuleContent retrieves module content from new files.

func (*Runner) GetNewResourceContent

func (r *Runner) GetNewResourceContent(resourceType string, schema *hclext.BodySchema, _ *tflint.GetModuleContentOption) (*hclext.BodyContent, error)

GetNewResourceContent retrieves resources of a specific type from new files.

func (*Runner) GetOldModuleContent

func (r *Runner) GetOldModuleContent(schema *hclext.BodySchema, _ *tflint.GetModuleContentOption) (*hclext.BodyContent, error)

GetOldModuleContent retrieves module content from old files.

func (*Runner) GetOldResourceContent

func (r *Runner) GetOldResourceContent(resourceType string, schema *hclext.BodySchema, _ *tflint.GetModuleContentOption) (*hclext.BodyContent, error)

GetOldResourceContent retrieves resources of a specific type from old files.

Jump to

Keyboard shortcuts

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