Documentation ¶
Index ¶
- Variables
- func ReferenceLink(name string) string
- func SeverityToInt32(s Severity) (int32, error)
- type Annotation
- type Annotations
- type Config
- type FileAnnotation
- type Issue
- type Issues
- type LineAnnotation
- type PluginConfig
- type Rule
- type RuleConfig
- type RuleSet
- type Runner
- func NewModuleRunners(parent *Runner) ([]*Runner, error)
- func NewRunner(originalWorkingDir string, c *Config, ants map[string]Annotations, ...) (*Runner, error)
- func TestRunner(t *testing.T, files map[string]string) *Runner
- func TestRunnerWithConfig(t *testing.T, files map[string]string, config *Config) *Runner
- func (r *Runner) ApplyChanges(changes map[string][]byte) hcl.Diagnostics
- func (r *Runner) ClearChanges()
- func (r *Runner) ConfigSources() map[string][]byte
- func (r *Runner) EmitIssue(rule Rule, message string, location hcl.Range, fixable bool) bool
- func (r *Runner) File(path string) *hcl.File
- func (r *Runner) Files() map[string]*hcl.File
- func (r *Runner) LookupChanges(files ...string) map[string][]byte
- func (r *Runner) LookupIssues(files ...string) Issues
- func (r *Runner) RuleConfig(ruleName string) *RuleConfig
- func (r *Runner) Sources() map[string][]byte
- func (r *Runner) WithExpressionContext(expr hcl.Expression, proc func() error) error
- type Severity
Constants ¶
This section is empty.
Variables ¶
var DisableBundledPlugin = false
DisbaleBundledPlugin is a flag to temporarily disable the bundled plugin for integration tests.
var Version *version.Version = version.Must(version.NewVersion("0.50.2"))
Version is application version
Functions ¶
func ReferenceLink ¶ added in v0.13.0
ReferenceLink returns the rule reference link
func SeverityToInt32 ¶ added in v0.45.0
Converts a severity into an ascending int32
Types ¶
type Annotation ¶ added in v0.13.0
Annotation represents comments with special meaning in TFLint
type Annotations ¶ added in v0.13.0
type Annotations []Annotation
Annotations is a slice of Annotation
func NewAnnotations ¶ added in v0.13.0
func NewAnnotations(path string, file *hcl.File) (Annotations, hcl.Diagnostics)
NewAnnotations find annotations from the passed tokens and return that list.
type Config ¶
type Config struct { CallModuleType terraform.CallModuleType CallModuleTypeSet bool Force bool ForceSet bool DisabledByDefault bool DisabledByDefaultSet bool PluginDir string PluginDirSet bool Format string FormatSet bool Varfiles []string Variables []string Only []string IgnoreModules map[string]bool Rules map[string]*RuleConfig Plugins map[string]*PluginConfig // contains filtered or unexported fields }
Config describes the behavior of TFLint
func EmptyConfig ¶
func EmptyConfig() *Config
EmptyConfig returns default config It is mainly used for testing
func LoadConfig ¶
LoadConfig loads TFLint config file. The priority of the configuration files is as follows:
1. file passed by the --config option 2. file set by the TFLINT_CONFIG_FILE environment variable 3. current directory (./.tflint.hcl) 4. home directory (~/.tflint.hcl)
For 1 and 2, if the file does not exist, an error will be returned immediately. If 3 fails, fallback to 4, and If it fails, an empty configuration is returned.
It also automatically enables bundled plugin if the "terraform" plugin block is not explicitly declared.
func (*Config) Merge ¶
Merge merges the two configs and applies to itself. Since the argument takes precedence, it can be used as overwriting of the config.
func (*Config) Sources ¶ added in v0.35.0
Sources returns parsed config file sources. To support bundle plugin config, this function returns c.sources with a merge of the pseudo config file.
func (*Config) ToPluginConfig ¶ added in v0.14.0
ToPluginConfig converts self into the plugin configuration format
func (*Config) ValidateRules ¶ added in v0.14.0
ValidateRules checks for duplicate rule names, for invalid rule names, and so on.
type FileAnnotation ¶ added in v0.49.0
FileAnnotation is an annotation for ignoring issues in a file
func (*FileAnnotation) IsAffected ¶ added in v0.49.0
func (a *FileAnnotation) IsAffected(issue *Issue) bool
IsAffected checks if the passed issue is affected with the annotation
func (*FileAnnotation) String ¶ added in v0.49.0
func (a *FileAnnotation) String() string
String returns the string representation of the annotation
type Issue ¶ added in v0.13.0
type Issue struct { Rule Rule Message string Range hcl.Range Fixable bool Callers []hcl.Range // Source is the source code of the file where the issue was found. // Usually this is the same as the originally loaded source, // but it may be a different if rewritten by autofixes. Source []byte }
Issue represents a problem in configurations
type LineAnnotation ¶ added in v0.49.0
LineAnnotation is an annotation for ignoring issues in a line
func (*LineAnnotation) IsAffected ¶ added in v0.49.0
func (a *LineAnnotation) IsAffected(issue *Issue) bool
IsAffected checks if the passed issue is affected with the annotation
func (*LineAnnotation) String ¶ added in v0.49.0
func (a *LineAnnotation) String() string
String returns the string representation of the annotation
type PluginConfig ¶ added in v0.13.0
type PluginConfig struct { Name string `hcl:"name,label"` Enabled bool `hcl:"enabled"` Version string `hcl:"version,optional"` Source string `hcl:"source,optional"` SigningKey string `hcl:"signing_key,optional"` Body hcl.Body `hcl:",remain"` // Parsed source attributes SourceHost string SourceOwner string SourceRepo string }
PluginConfig is a TFLint's plugin config
func (*PluginConfig) Content ¶ added in v0.36.0
func (c *PluginConfig) Content(schema *hclext.BodySchema) (*hclext.BodyContent, hcl.Diagnostics)
Content extracts a plugin config based on the passed schema.
type RuleConfig ¶
type RuleConfig struct { Name string `hcl:"name,label"` Enabled bool `hcl:"enabled"` Body hcl.Body `hcl:",remain"` }
RuleConfig is a TFLint's rule config
type RuleSet ¶ added in v0.14.0
type RuleSet interface { RuleSetName() (string, error) RuleSetVersion() (string, error) RuleNames() ([]string, error) }
RuleSet is an interface to handle plugin's RuleSet. The real impl is github.com/terraform-linters/tflint-plugin-sdk/plugin/host2plugin.GRPCClient.
type Runner ¶
type Runner struct { TFConfig *terraform.Config Issues Issues Ctx *terraform.Evaluator // contains filtered or unexported fields }
Runner checks templates according rules. For variables interplation, it has Terraform eval context. After checking, it accumulates results as issues.
func NewModuleRunners ¶
NewModuleRunners returns new TFLint runners for child modules Recursively search modules and generate Runners In order to propagate attributes of moduleCall as variables to the module, evaluate the variables. If it cannot be evaluated, treat it as unknown Modules that are not evaluated (`count` is 0 or `for_each` is empty) are ignored.
func NewRunner ¶
func NewRunner(originalWorkingDir string, c *Config, ants map[string]Annotations, cfg *terraform.Config, variables ...terraform.InputValues) (*Runner, error)
NewRunner returns new TFLint runner. It prepares built-in context (workpace metadata, variables) from received `terraform.Config` and `terraform.InputValues`.
func TestRunner ¶ added in v0.13.0
TestRunner returns a runner for testing. Note that this runner ignores a config, annotations, and input variables.
func TestRunnerWithConfig ¶ added in v0.15.0
TestRunnerWithConfig returns a runner with passed config for testing.
func (*Runner) ApplyChanges ¶ added in v0.47.0
func (r *Runner) ApplyChanges(changes map[string][]byte) hcl.Diagnostics
ApplyChanges saves the changes and applies them to the Terraform module.
func (*Runner) ClearChanges ¶ added in v0.47.0
func (r *Runner) ClearChanges()
ClearChanges clears changes
func (*Runner) ConfigSources ¶ added in v0.36.0
ConfigSources returns the sources of TFLint config files
func (*Runner) EmitIssue ¶
EmitIssue builds an issue and accumulates it. Returns true if the issue was not ignored by annotations.
func (*Runner) File ¶ added in v0.16.1
File returns the raw *hcl.File representation of a Terraform configuration at the specified path, or nil if there path does not match any configuration.
func (*Runner) Files ¶ added in v0.16.1
Files returns the raw *hcl.File representation of all Terraform configuration in the module directory.
func (*Runner) LookupChanges ¶ added in v0.47.0
LookupChanges returns changes according to the received files
func (*Runner) LookupIssues ¶
LookupIssues returns issues according to the received files
func (*Runner) RuleConfig ¶ added in v0.23.0
func (r *Runner) RuleConfig(ruleName string) *RuleConfig
RuleConfig returns the corresponding rule configuration
func (*Runner) WithExpressionContext ¶ added in v0.14.0
func (r *Runner) WithExpressionContext(expr hcl.Expression, proc func() error) error
WithExpressionContext sets the context of the passed expression currently being processed.