Documentation ¶
Index ¶
- Constants
- type AbstractLoader
- type Config
- type Error
- type Loader
- 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) EvaluateExpr(expr hcl.Expression, ret interface{}) error
- func (r *Runner) IsNullExpr(expr hcl.Expression) bool
- func (r *Runner) LookupIssues(files ...string) issue.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 // 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 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbstractLoader ¶
type AbstractLoader interface { LoadConfig() (*configs.Config, error) LoadValuesFiles(...string) ([]terraform.InputValues, error) IsConfigFile(string) bool }
AbstractLoader is a loader interface for mock
type Config ¶
type Config struct { DeepCheck bool AwsCredentials client.AwsCredentials IgnoreModule map[string]bool IgnoreRule map[string]bool Varfile []string TerraformVersion 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.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is a wrapper of Terraform's configload.Loader
func (*Loader) IsConfigFile ¶
IsConfigFile checks whether the configuration files includes the file
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 RuleConfig ¶
RuleConfig is a TFLint's rule config
type Runner ¶
type Runner struct { TFConfig *configs.Config Issues issue.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 ¶
NewRunner returns new TFLint runner It prepares built-in context (workpace metadata, variables) from received `configs.Config` and `terraform.InputValues`
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) 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
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