terraform

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MPL-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Preset string `hclext:"preset,optional"`
}

Config is the configuration for the ruleset.

type Local

type Local struct {
	Name      string
	Attribute *hcl.Attribute
	DefRange  hcl.Range
}

Local represents a single entry from a "locals" block.

type ModuleCall

type ModuleCall struct {
	Name        string
	DefRange    hcl.Range
	Source      string
	SourceAttr  *hclext.Attribute
	Version     version.Constraints
	VersionAttr *hclext.Attribute
}

ModuleCall represents a "module" block.

type ProviderRef

type ProviderRef struct {
	Name     string
	DefRange hcl.Range
}

ProviderRef represents a reference to a provider like `provider = google.europe` in a resource or module.

type RuleSet

type RuleSet struct {
	tflint.BuiltinRuleSet

	PresetRules map[string][]tflint.Rule
	// contains filtered or unexported fields
}

RuleSet is the custom ruleset for the Terraform Language.

func (*RuleSet) ApplyConfig

func (r *RuleSet) ApplyConfig(body *hclext.BodyContent) error

ApplyConfig controls rule activation based on global and preset configs. The priority of rules is in the following order:

  1. --only option
  2. Rule config declared in each "rule" block
  3. Preset config declared in "plugin" block
  4. The `disabled_by_default` declared in global "config" block

Individual rule configs always take precedence over anything else. Preset rules are then prioritized. For example, if `disabled_by_default = true` and `preset = "recommended"` is declared, all recommended rules will be enabled.

func (*RuleSet) ApplyGlobalConfig

func (r *RuleSet) ApplyGlobalConfig(config *tflint.Config) error

ApplyGlobalConfig is normally not expected to be overridden, but here the preset setting takes precedence over DisabledByDefault, so it just overrides and saves the global config to the ruleset.

func (*RuleSet) ConfigSchema

func (r *RuleSet) ConfigSchema() *hclext.BodySchema

func (*RuleSet) NewRunner added in v0.4.0

func (r *RuleSet) NewRunner(runner tflint.Runner) (tflint.Runner, error)

NewRunner injects a custom runner

func (*RuleSet) RuleNames

func (r *RuleSet) RuleNames() []string

type Runner

type Runner struct {
	tflint.Runner
}

Runner is a custom runner that provides helper functions for this ruleset.

func NewRunner

func NewRunner(runner tflint.Runner) *Runner

NewRunner returns a new custom runner.

func (*Runner) GetLocals

func (r *Runner) GetLocals() (map[string]*Local, hcl.Diagnostics)

GetLocals returns all entries in "locals" blocks.

func (*Runner) GetModuleCalls

func (r *Runner) GetModuleCalls() ([]*ModuleCall, hcl.Diagnostics)

GetModuleCalls returns all "module" blocks, including uncreated module calls.

func (*Runner) GetProviderRefs

func (r *Runner) GetProviderRefs() (map[string]*ProviderRef, hcl.Diagnostics)

GetProviderRefs returns all references to providers in resources, data, provider declarations, and module calls.

Jump to

Keyboard shortcuts

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