Documentation ¶
Overview ¶
Package tflint is a generated GoMock package.
Index ¶
- Constants
- func AssertAppError(t *testing.T, expected Error, got error)
- 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
- type Error
- type Issue
- type Issues
- type Loader
- type MockAbstractLoader
- func (m *MockAbstractLoader) EXPECT() *MockAbstractLoaderMockRecorder
- 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) 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 ProviderConfig
- type Rule
- type RuleConfig
- type Runner
- func (r *Runner) EachStringSliceExprs(expr hcl.Expression, proc func(val string, expr hcl.Expression)) error
- func (r *Runner) EmitIssue(rule Rule, message string, location hcl.Range)
- func (r *Runner) EnsureNoError(err error, proc func() error) error
- func (r *Runner) EvaluateBlock(block *hcl.Block, schema *configschema.Block, ret interface{}) error
- func (r *Runner) EvaluateExpr(expr hcl.Expression, ret interface{}) error
- func (r *Runner) IsNullExpr(expr hcl.Expression) (bool, error)
- func (r *Runner) LookupIssues(files ...string) Issues
- func (r *Runner) LookupResourcesByType(resourceType string) []*configs.Resource
- func (r *Runner) TFConfigPath() string
- func (r *Runner) WalkResourceAttributes(resource, attributeName string, walker func(*hcl.Attribute) error) error
- func (r *Runner) WalkResourceBlocks(resource, blockType string, walker func(*hcl.Block) error) error
Constants ¶
const ( // EvaluationError is an error when interpolation failed (unexpected) EvaluationError int = 0 // UnknownValueError is an error when an unknown value is referenced UnknownValueError int = 1 + iota // NullValueError is an error when null value is referenced NullValueError // TypeConversionError is an error when type conversion of cty.Value failed TypeConversionError // TypeMismatchError is an error when a type of cty.Value is not as expected TypeMismatchError // UnevaluableError is an error when a received expression has unevaluable references. UnevaluableError // UnexpectedAttributeError is an error when handle unexpected attributes (e.g. block) UnexpectedAttributeError // ExternalAPIError is an error when calling the external API (e.g. AWS SDK) ExternalAPIError // ContextError is pseudo error code for propagating runtime context. ContextError // FatalLevel is a recorverable error, it cause panic FatalLevel int = 0 // ErrorLevel is a user-level error, it display and feedback error information ErrorLevel int = 1 + iota // WarningLevel is a user-level warning. Although it is an error, it has no effect on execution. WarningLevel )
const ( // ERROR is possible errors ERROR = "Error" // WARNING doesn't cause problem immediately, but not good WARNING = "Warning" // NOTICE is not important, it's mentioned NOTICE = "Notice" )
const Version string = "0.12.1"
Version is application version
Variables ¶
This section is empty.
Functions ¶
func AssertAppError ¶ added in v0.11.0
AssertAppError is an assertion helper for comparing tflint.Error
func AssertIssues ¶ added in v0.11.0
AssertIssues is an assertion helper for comparing issues
func AssertIssuesWithoutRange ¶ added in v0.11.0
AssertIssuesWithoutRange is an assertion helper for comparing issues
func ParseTFVariables ¶ added in v0.8.3
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.12.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) Sources() map[string][]byte }
AbstractLoader is a loader interface for mock
type Annotation ¶ added in v0.8.1
Annotation represents comments with special meaning in TFLint
func (*Annotation) IsAffected ¶ added in v0.8.1
func (a *Annotation) IsAffected(issue *Issue) bool
IsAffected checks if the passed issue is affected with the annotation
func (*Annotation) String ¶ added in v0.8.1
func (a *Annotation) String() string
String returns the string representation of the annotation
type Annotations ¶ added in v0.8.1
type Annotations []Annotation
Annotations is slice of Annotation
func NewAnnotations ¶ added in v0.8.1
func NewAnnotations(tokens hclsyntax.Tokens) Annotations
NewAnnotations find annotations from the passed tokens and return that list.
type Config ¶
type Config struct { Module bool DeepCheck bool Force bool AwsCredentials client.AwsCredentials IgnoreModules map[string]bool Varfiles []string Variables []string Rules map[string]*RuleConfig }
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
type Error ¶
Error is application error object. It has own error code for processing according to a type of error.
func NewContextError ¶ added in v0.11.0
NewContextError makes a new context error
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is a wrapper of Terraform's configload.Loader
func (*Loader) LoadAnnotations ¶ added in v0.8.1
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.8.1
type MockAbstractLoader struct {
// contains filtered or unexported fields
}
MockAbstractLoader is a mock of AbstractLoader interface
func NewMockAbstractLoader ¶ added in v0.8.1
func NewMockAbstractLoader(ctrl *gomock.Controller) *MockAbstractLoader
NewMockAbstractLoader creates a new mock instance
func (*MockAbstractLoader) EXPECT ¶ added in v0.8.1
func (m *MockAbstractLoader) EXPECT() *MockAbstractLoaderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockAbstractLoader) LoadAnnotations ¶ added in v0.8.1
func (m *MockAbstractLoader) LoadAnnotations(arg0 string) (map[string]Annotations, error)
LoadAnnotations mocks base method
func (*MockAbstractLoader) LoadConfig ¶ added in v0.8.1
func (m *MockAbstractLoader) LoadConfig(arg0 string) (*configs.Config, error)
LoadConfig mocks base method
func (*MockAbstractLoader) LoadValuesFiles ¶ added in v0.8.1
func (m *MockAbstractLoader) LoadValuesFiles(arg0 ...string) ([]terraform.InputValues, error)
LoadValuesFiles mocks base method
func (*MockAbstractLoader) Sources ¶ added in v0.11.0
func (m *MockAbstractLoader) Sources() map[string][]byte
Sources mocks base method
type MockAbstractLoaderMockRecorder ¶ added in v0.8.1
type MockAbstractLoaderMockRecorder struct {
// contains filtered or unexported fields
}
MockAbstractLoaderMockRecorder is the mock recorder for MockAbstractLoader
func (*MockAbstractLoaderMockRecorder) LoadAnnotations ¶ added in v0.8.1
func (mr *MockAbstractLoaderMockRecorder) LoadAnnotations(arg0 interface{}) *gomock.Call
LoadAnnotations indicates an expected call of LoadAnnotations
func (*MockAbstractLoaderMockRecorder) LoadConfig ¶ added in v0.8.1
func (mr *MockAbstractLoaderMockRecorder) LoadConfig(arg0 interface{}) *gomock.Call
LoadConfig indicates an expected call of LoadConfig
func (*MockAbstractLoaderMockRecorder) LoadValuesFiles ¶ added in v0.8.1
func (mr *MockAbstractLoaderMockRecorder) LoadValuesFiles(arg0 ...interface{}) *gomock.Call
LoadValuesFiles indicates an expected call of LoadValuesFiles
func (*MockAbstractLoaderMockRecorder) Sources ¶ added in v0.11.0
func (mr *MockAbstractLoaderMockRecorder) Sources() *gomock.Call
Sources indicates an expected call of Sources
type ProviderConfig ¶ added in v0.10.1
type ProviderConfig struct {
// contains filtered or unexported fields
}
ProviderConfig represents a provider block with an eval context (runner)
func NewProviderConfig ¶ added in v0.10.1
func NewProviderConfig(tfProvider *configs.Provider, runner *Runner, schema *hcl.BodySchema) (*ProviderConfig, error)
NewProviderConfig returns a provider config from the given `configs.Provider` and runner
func (*ProviderConfig) Get ¶ added in v0.10.1
func (p *ProviderConfig) Get(key string) (string, bool, error)
Get returns a value corresponding to the given key It should be noted that the value is evaluated if it is evaluable The second return value is a flag that determines whether a value exists We assume the provider has only simple attributes, so it just returns string
func (*ProviderConfig) GetBlock ¶ added in v0.11.0
func (p *ProviderConfig) GetBlock(key string, schema *configschema.Block) (map[string]string, bool, error)
GetBlock is Get for blocks. Obviously from the return type, nested blocks and blocks with complex types are not supported. Also note that all attributes are lost if the given block contains unevalable expressions because the entire block is evaluated.
type RuleConfig ¶
RuleConfig is a TFLint's rule config
type Runner ¶
type Runner struct { TFConfig *configs.Config Issues Issues AwsClient *client.AwsClient // 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, 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.11.0
TestRunner returns a runner for testing. Note that this runner ignores a config, annotations, and input variables.
func (*Runner) EachStringSliceExprs ¶
func (r *Runner) EachStringSliceExprs(expr hcl.Expression, proc func(val string, expr hcl.Expression)) error
EachStringSliceExprs iterates an evaluated value and the corresponding expression If the given expression is a static list, get an expression for each value If not, the given expression is used as it is
func (*Runner) EnsureNoError ¶
EnsureNoError is a helper for processing when no error occurs This function skips processing without returning an error to the caller when the error is warning
func (*Runner) EvaluateBlock ¶ added in v0.11.0
EvaluateBlock is a wrapper of terraform.BultinEvalContext.EvaluateBlock and gocty.FromCtyValue
func (*Runner) EvaluateExpr ¶
func (r *Runner) EvaluateExpr(expr hcl.Expression, ret interface{}) error
EvaluateExpr is a wrapper of terraform.BultinEvalContext.EvaluateExpr and gocty.FromCtyValue When it received slice as `ret`, it converts cty.Value to expected list type because raw cty.Value has TupleType.
func (*Runner) IsNullExpr ¶
func (r *Runner) IsNullExpr(expr hcl.Expression) (bool, error)
IsNullExpr check the passed expression is null
func (*Runner) LookupIssues ¶
LookupIssues returns issues according to the received files
func (*Runner) LookupResourcesByType ¶
LookupResourcesByType returns `configs.Resource` list according to the resource type
func (*Runner) TFConfigPath ¶
TFConfigPath is a wrapper of addrs.Module