Documentation
¶
Index ¶
- Constants
- type AttributesRequest
- type AttributesResponse
- type Client
- func (c *Client) EmitIssue(rule Rule, message string, location hcl.Range, meta Metadata) error
- func (*Client) EnsureNoError(err error, proc func() error) error
- func (c *Client) EvaluateExpr(expr hcl.Expression, ret interface{}) error
- func (c *Client) WalkResourceAttributes(resource, attributeName string, walker func(*hcl.Attribute) error) error
- type Config
- type EmitIssueRequest
- type Error
- type EvalExprRequest
- type EvalExprResponse
- type Metadata
- type Rule
- type RuleConfig
- type RuleObject
- type RuleObjectData
- type RuleSet
- type Runner
- type Server
Constants ¶
const ( // EvaluationError is an error when interpolation failed (unexpected) EvaluationError string = "E:Evaluation" // UnknownValueError is an error when an unknown value is referenced UnknownValueError string = "W:UnknownValue" // NullValueError is an error when null value is referenced NullValueError string = "W:NullValue" // TypeConversionError is an error when type conversion of cty.Value failed TypeConversionError string = "E:TypeConversion" // TypeMismatchError is an error when a type of cty.Value is not as expected TypeMismatchError string = "E:TypeMismatch" // UnevaluableError is an error when a received expression has unevaluable references. UnevaluableError string = "W:Unevaluable" // UnexpectedAttributeError is an error when handle unexpected attributes (e.g. block) UnexpectedAttributeError string = "E:UnexpectedAttribute" // ExternalAPIError is an error when calling the external API (e.g. AWS SDK) ExternalAPIError string = "E:ExternalAPI" // ContextError is pseudo error code for propagating runtime context. ContextError string = "I:Context" // FatalLevel is a recorverable error, it cause panic FatalLevel string = "Fatal" // ErrorLevel is a user-level error, it display and feedback error information ErrorLevel string = "Error" // WarningLevel is a user-level warning. Although it is an error, it has no effect on execution. WarningLevel string = "Warning" )
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" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributesRequest ¶
AttributesRequest is the interface used to communicate via RPC.
type AttributesResponse ¶
AttributesResponse is the interface used to communicate via RPC.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an RPC client for plugins to query the host process for Terraform configurations Actually, it is an RPC client, but its details are hidden on the plugin side because it satisfies the Runner interface
func (*Client) EmitIssue ¶
EmitIssue emits attributes to build the issue to the host process Note that the passed rule need to be converted to generic objects because the custom structure defined in the plugin cannot be sent via RPC.
func (*Client) 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 (*Client) EvaluateExpr ¶
func (c *Client) EvaluateExpr(expr hcl.Expression, ret interface{}) error
EvaluateExpr queries the host process for the result of evaluating the value of the passed expression and reflects it as the value of the second argument based on that.
type Config ¶
type Config struct {
Rules map[string]*RuleConfig
}
Config is a TFLint configuration applied to a plugin At this time, it is not expected that each plugin will reference this directly
type EmitIssueRequest ¶
type EmitIssueRequest struct {
Rule *RuleObject
Message string
Location hcl.Range
Meta Metadata
}
EmitIssueRequest is the interface used to communicate via RPC.
type Error ¶
Error is application error object. It has own error code for processing according to a type of error.
type EvalExprRequest ¶
type EvalExprRequest struct {
Expr hcl.Expression
Ret interface{}
}
EvalExprRequest is the interface used to communicate via RPC.
type EvalExprResponse ¶
EvalExprResponse is the interface used to communicate with RPC.
type Metadata ¶
type Metadata struct {
Expr hcl.Expression
}
Metadata is the additional data sent to the host process to build the issue.
type Rule ¶
type Rule interface {
Name() string
Enabled() bool
Severity() string
Link() string
Check(Runner) error
}
Rule is the interface that the plugin's rules should satisfy.
type RuleConfig ¶
RuleConfig is a TFLint's rule config
type RuleObject ¶
type RuleObject struct {
Data *RuleObjectData
}
RuleObject is an intermediate representation for communicating with RPC.
func (*RuleObject) Enabled ¶
func (r *RuleObject) Enabled() bool
Enabled is a reference method to internal data
func (*RuleObject) Link ¶
func (r *RuleObject) Link() string
Link is a reference method to internal data
func (*RuleObject) Name ¶
func (r *RuleObject) Name() string
Name is a reference method to internal data
func (*RuleObject) Severity ¶
func (r *RuleObject) Severity() string
Severity is a reference method to internal data
type RuleObjectData ¶
RuleObjectData holds the data that RuleObject needs to satisfy the Rule interface.
type RuleSet ¶
RuleSet is a list of rules that a plugin should provide
func (*RuleSet) ApplyConfig ¶
ApplyConfig reflects the plugin configuration in the ruleset. Currently used only to enable/disable rules.
func (*RuleSet) RuleSetName ¶
RuleSetName is the name of the rule set. Generally, this is synonymous with the name of the plugin.
func (*RuleSet) RuleSetVersion ¶
RuleSetVersion is the version of the plugin.
type Runner ¶
type Runner interface {
WalkResourceAttributes(string, string, func(*hcl.Attribute) error) error
EvaluateExpr(expr hcl.Expression, ret interface{}) error
EmitIssue(rule Rule, message string, location hcl.Range, meta Metadata) error
EnsureNoError(error, func() error) error
}
Runner acts as a client for each plugin to query the host process about the Terraform configurations.
type Server ¶
type Server interface {
Attributes(*AttributesRequest, *AttributesResponse) error
EvalExpr(*EvalExprRequest, *EvalExprResponse) error
EmitIssue(*EmitIssueRequest, *interface{}) error
}
Server is the interface that hosts that provide the plugin mechanism must meet in order to respond to queries from the plugin.