Documentation ¶
Overview ¶
Package tflint is a generated GoMock package.
Index ¶
- Constants
- func AssertIssues(t *testing.T, expected Issues, actual Issues)
- func AssertIssuesWithoutRange(t *testing.T, expected Issues, actual Issues)
- func ParseTFVariables(vars []string, declVars map[string]*configs.Variable) (terraform.InputValues, error)
- func ReferenceLink(name string) string
- type AbstractLoader
- type Annotation
- type Annotations
- type Config
- func (c *Config) Merge(other *Config) *Config
- func (c *Config) PluginContent(name string, schema *hclext.BodySchema) (*hclext.BodyContent, hcl.Diagnostics)
- func (c *Config) Sources() map[string][]byte
- func (c *Config) ToPluginConfig() *sdk.Config
- func (c *Config) ValidateRules(rulesets ...RuleSet) error
- type Issue
- type Issues
- type Loader
- func (l *Loader) Files() (map[string]*hcl.File, error)
- func (l *Loader) LoadAnnotations(dir string) (map[string]Annotations, error)
- func (l *Loader) LoadConfig(dir string) (*configs.Config, error)
- func (l *Loader) LoadValuesFiles(files ...string) ([]terraform.InputValues, error)
- func (l *Loader) Sources() map[string][]byte
- type MockAbstractLoader
- func (m *MockAbstractLoader) EXPECT() *MockAbstractLoaderMockRecorder
- func (m *MockAbstractLoader) Files() (map[string]*v2.File, error)
- func (m *MockAbstractLoader) LoadAnnotations(arg0 string) (map[string]Annotations, error)
- func (m *MockAbstractLoader) LoadConfig(arg0 string) (*configs.Config, error)
- func (m *MockAbstractLoader) LoadValuesFiles(arg0 ...string) ([]terraform.InputValues, error)
- func (m *MockAbstractLoader) Sources() map[string][]byte
- type MockAbstractLoaderMockRecorder
- func (mr *MockAbstractLoaderMockRecorder) Files() *gomock.Call
- func (mr *MockAbstractLoaderMockRecorder) LoadAnnotations(arg0 interface{}) *gomock.Call
- func (mr *MockAbstractLoaderMockRecorder) LoadConfig(arg0 interface{}) *gomock.Call
- func (mr *MockAbstractLoaderMockRecorder) LoadValuesFiles(arg0 ...interface{}) *gomock.Call
- func (mr *MockAbstractLoaderMockRecorder) Sources() *gomock.Call
- type PluginConfig
- type Rule
- type RuleConfig
- type RuleSet
- type Runner
- func NewModuleRunners(parent *Runner) ([]*Runner, error)
- func NewRunner(c *Config, files map[string]*hcl.File, 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) ConfigFile() *hcl.File
- func (r *Runner) DecodeRuleConfig(ruleName string, val interface{}) error
- func (r *Runner) EmitIssue(rule Rule, message string, location hcl.Range)
- func (r *Runner) EvaluateExpr(expr hcl.Expression, wantType cty.Type) (cty.Value, error)
- func (r *Runner) File(path string) *hcl.File
- func (r *Runner) Files() map[string]*hcl.File
- func (r *Runner) GetModuleContent(bodyS *hclext.BodySchema, opts sdk.GetModuleContentOption) (*hclext.BodyContent, hcl.Diagnostics)
- func (r *Runner) LookupIssues(files ...string) Issues
- func (r *Runner) RuleConfig(ruleName string) *RuleConfig
- func (r *Runner) Sources() map[string][]byte
- func (r *Runner) TFConfigPath() string
- func (r *Runner) WalkExpressions(walker func(hcl.Expression) error) error
- func (r *Runner) WithExpressionContext(expr hcl.Expression, proc func() error) error
- type Severity
Constants ¶
const Version string = "0.35.0"
Version is application version
Variables ¶
This section is empty.
Functions ¶
func AssertIssues ¶ added in v0.13.0
AssertIssues is an assertion helper for comparing issues
func AssertIssuesWithoutRange ¶ added in v0.13.0
AssertIssuesWithoutRange is an assertion helper for comparing issues
func ParseTFVariables ¶ added in v0.13.0
func ParseTFVariables(vars []string, declVars map[string]*configs.Variable) (terraform.InputValues, error)
ParseTFVariables parses the passed Terraform variable CLI arguments, and returns terraform.InputValues
func ReferenceLink ¶ added in v0.13.0
ReferenceLink returns the rule reference link
Types ¶
type AbstractLoader ¶
type AbstractLoader interface { LoadConfig(string) (*configs.Config, error) LoadAnnotations(string) (map[string]Annotations, error) LoadValuesFiles(...string) ([]terraform.InputValues, error) Files() (map[string]*hcl.File, error) Sources() map[string][]byte }
AbstractLoader is a loader interface for mock
type Annotation ¶ added in v0.13.0
Annotation represents comments with special meaning in TFLint
func (*Annotation) IsAffected ¶ added in v0.13.0
func (a *Annotation) IsAffected(issue *Issue) bool
IsAffected checks if the passed issue is affected with the annotation
func (*Annotation) String ¶ added in v0.13.0
func (a *Annotation) String() string
String returns the string representation of the annotation
type Annotations ¶ added in v0.13.0
type Annotations []Annotation
Annotations is slice of Annotation
func NewAnnotations ¶ added in v0.13.0
func NewAnnotations(tokens hclsyntax.Tokens) Annotations
NewAnnotations find annotations from the passed tokens and return that list.
type Config ¶
type Config struct { Module bool Force bool IgnoreModules map[string]bool Varfiles []string Variables []string DisabledByDefault bool PluginDir string 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 from file If failed to load the default config file, it tries to load config file under the home directory Therefore, if there is no default config file, it will not return an error
func (*Config) Merge ¶
Merge returns a merged copy of the two configs Since the argument takes precedence, it can be used as overwriting of the config
func (*Config) PluginContent ¶ added in v0.35.0
func (c *Config) PluginContent(name string, schema *hclext.BodySchema) (*hclext.BodyContent, hcl.Diagnostics)
PluginContent returns config content of the passed rule based on the schema.
func (*Config) Sources ¶ added in v0.35.0
Sources returns parsed config file sources. Normally, there is only one file, but it is represented by map to retain the file name.
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 Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is a wrapper of Terraform's configload.Loader
func (*Loader) Files ¶ added in v0.16.1
Files returns a map of hcl.File pointers for every file that has been read by the loader. It uses the source cache to avoid re-loading the files from disk. These files can be used to do low level decoding of Terraform configuration.
func (*Loader) LoadAnnotations ¶ added in v0.13.0
func (l *Loader) LoadAnnotations(dir string) (map[string]Annotations, error)
LoadAnnotations load TFLint annotation comments as HCL tokens.
func (*Loader) LoadConfig ¶
LoadConfig loads Terraform's configurations TODO: Can we use configload.LoadConfig instead?
func (*Loader) LoadValuesFiles ¶
func (l *Loader) LoadValuesFiles(files ...string) ([]terraform.InputValues, error)
LoadValuesFiles reads Terraform's values files and returns terraform.InputValues list in order of priority Pass values files specified from the CLI as the arguments in order of priority This is the responsibility of the caller
type MockAbstractLoader ¶ added in v0.13.0
type MockAbstractLoader struct {
// contains filtered or unexported fields
}
MockAbstractLoader is a mock of AbstractLoader interface.
func NewMockAbstractLoader ¶ added in v0.13.0
func NewMockAbstractLoader(ctrl *gomock.Controller) *MockAbstractLoader
NewMockAbstractLoader creates a new mock instance.
func (*MockAbstractLoader) EXPECT ¶ added in v0.13.0
func (m *MockAbstractLoader) EXPECT() *MockAbstractLoaderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockAbstractLoader) Files ¶ added in v0.16.1
func (m *MockAbstractLoader) Files() (map[string]*v2.File, error)
Files mocks base method.
func (*MockAbstractLoader) LoadAnnotations ¶ added in v0.13.0
func (m *MockAbstractLoader) LoadAnnotations(arg0 string) (map[string]Annotations, error)
LoadAnnotations mocks base method.
func (*MockAbstractLoader) LoadConfig ¶ added in v0.13.0
func (m *MockAbstractLoader) LoadConfig(arg0 string) (*configs.Config, error)
LoadConfig mocks base method.
func (*MockAbstractLoader) LoadValuesFiles ¶ added in v0.13.0
func (m *MockAbstractLoader) LoadValuesFiles(arg0 ...string) ([]terraform.InputValues, error)
LoadValuesFiles mocks base method.
func (*MockAbstractLoader) Sources ¶ added in v0.13.0
func (m *MockAbstractLoader) Sources() map[string][]byte
Sources mocks base method.
type MockAbstractLoaderMockRecorder ¶ added in v0.13.0
type MockAbstractLoaderMockRecorder struct {
// contains filtered or unexported fields
}
MockAbstractLoaderMockRecorder is the mock recorder for MockAbstractLoader.
func (*MockAbstractLoaderMockRecorder) Files ¶ added in v0.16.1
func (mr *MockAbstractLoaderMockRecorder) Files() *gomock.Call
Files indicates an expected call of Files.
func (*MockAbstractLoaderMockRecorder) LoadAnnotations ¶ added in v0.13.0
func (mr *MockAbstractLoaderMockRecorder) LoadAnnotations(arg0 interface{}) *gomock.Call
LoadAnnotations indicates an expected call of LoadAnnotations.
func (*MockAbstractLoaderMockRecorder) LoadConfig ¶ added in v0.13.0
func (mr *MockAbstractLoaderMockRecorder) LoadConfig(arg0 interface{}) *gomock.Call
LoadConfig indicates an expected call of LoadConfig.
func (*MockAbstractLoaderMockRecorder) LoadValuesFiles ¶ added in v0.13.0
func (mr *MockAbstractLoaderMockRecorder) LoadValuesFiles(arg0 ...interface{}) *gomock.Call
LoadValuesFiles indicates an expected call of LoadValuesFiles.
func (*MockAbstractLoaderMockRecorder) Sources ¶ added in v0.13.0
func (mr *MockAbstractLoaderMockRecorder) Sources() *gomock.Call
Sources indicates an expected call of Sources.
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 SourceOwner string SourceRepo string // contains filtered or unexported fields }
PluginConfig is a TFLint's plugin config
type RuleConfig ¶
type RuleConfig struct { Name string `hcl:"name,label"` Enabled bool `hcl:"enabled"` Body hcl.Body `hcl:",remain"` // contains filtered or unexported fields }
RuleConfig is a TFLint's rule config
func (*RuleConfig) Bytes ¶ added in v0.23.0
func (r *RuleConfig) Bytes() []byte
Bytes returns the bytes of the configuration file declared in the rule.
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 and core RuleSet both In the future, when all RuleSets are cut out into plugins, it will no longer be needed.
type Runner ¶
type Runner struct { TFConfig *configs.Config Issues Issues // 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
func NewRunner ¶
func NewRunner(c *Config, files map[string]*hcl.File, ants map[string]Annotations, cfg *configs.Config, variables ...terraform.InputValues) (*Runner, error)
NewRunner returns new TFLint runner It prepares built-in context (workpace metadata, variables) from received `configs.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) ConfigFile ¶ added in v0.35.0
func (*Runner) DecodeRuleConfig ¶ added in v0.15.0
DecodeRuleConfig extracts the rule's configuration into the given value
func (*Runner) EvaluateExpr ¶
EvaluateExpr is a wrapper of terraform.BultinEvalContext.EvaluateExpr In addition, it returns an error if expr cannot be evaluated, if it contains an unknown value, or if it contains null. However, it allows null and unknown only for DynamicPseudoType.
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) GetModuleContent ¶ added in v0.35.0
func (r *Runner) GetModuleContent(bodyS *hclext.BodySchema, opts sdk.GetModuleContentOption) (*hclext.BodyContent, hcl.Diagnostics)
GetModuleContent extracts body content from Terraform configurations based on the passed schema. Basically, this function is a wrapper for hclext.PartialContent, but in some ways it reproduces Terraform language semantics.
- The block schema implicitly adds dynamic blocks to the target https://www.terraform.io/language/expressions/dynamic-blocks
- Supports overriding files https://www.terraform.io/language/files/override
- Resources not created by count or for_each will be ignored https://www.terraform.io/language/meta-arguments/count https://www.terraform.io/language/meta-arguments/for_each
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) TFConfigPath ¶
TFConfigPath is a wrapper of addrs.Module
func (*Runner) WalkExpressions ¶ added in v0.16.0
func (r *Runner) WalkExpressions(walker func(hcl.Expression) error) error
WalkExpressions visits all blocks that can contain expressions: resource, data, module, provider, locals, and output. It calls the walker function with every expression it encounters and halts if the walker returns an error.
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.