Documentation ¶
Overview ¶
Package client contains the implementations required for plugins to act as a client. Developers typically query via the Runner interface, so they don't need to be aware of this layer.
The client is the actual entity that satisfies the interface. It sends a request to the host via RPC, decodes the response, and provides APIs for plugins.
Complex structures such as hcl.Expression and hcl.Body are sent/received as byte slices and range. Plugins and host parse the byte slice to get the original object.
Index ¶
- type Attribute
- type AttributesRequest
- type AttributesResponse
- type Backend
- type BackendRequest
- type BackendResponse
- type Block
- type BlocksRequest
- type BlocksResponse
- type Client
- func (c *Client) Backend() (*configs.Backend, error)
- func (c *Client) Config() (*configs.Config, error)
- func (c *Client) DecodeRuleConfig(name string, ret interface{}) error
- func (c *Client) EmitIssue(rule tflint.Rule, message string, location hcl.Range) error
- func (c *Client) EmitIssueOnExpr(rule tflint.Rule, message string, expr hcl.Expression) error
- func (*Client) EnsureNoError(err error, proc func() error) error
- func (c *Client) EvaluateExpr(expr hcl.Expression, ret interface{}, wantType *cty.Type) error
- func (c *Client) EvaluateExprOnRootCtx(expr hcl.Expression, ret interface{}, wantType *cty.Type) error
- func (c *Client) File(filename string) (*hcl.File, error)
- func (c *Client) Files() (map[string]*hcl.File, error)
- func (c *Client) IsNullExpr(expr hcl.Expression) (bool, error)
- func (c *Client) RootProvider(name string) (*configs.Provider, error)
- func (c *Client) WalkModuleCalls(walker func(*configs.ModuleCall) error) error
- func (c *Client) WalkResourceAttributes(resource, attributeName string, walker func(*hcl.Attribute) error) error
- func (c *Client) WalkResourceBlocks(resource, blockType string, walker func(*hcl.Block) error) error
- func (c *Client) WalkResources(resource string, walker func(*configs.Resource) error) error
- type Config
- type ConfigRequest
- type ConfigResponse
- type Connection
- type EmitIssueRequest
- type EvalExprRequest
- type EvalExprResponse
- type FileRequest
- type FileResponse
- type FilesRequest
- type FilesResponse
- type IsNullExprRequest
- type IsNullExprResponse
- type Local
- type ManagedResource
- type Module
- type ModuleCall
- type ModuleCallsRequest
- type ModuleCallsResponse
- type Output
- type PassedProviderConfig
- type Provider
- type ProviderMeta
- type Provisioner
- type RequiredProvider
- type RequiredProviders
- type Resource
- type ResourcesRequest
- type ResourcesResponse
- type RootProviderRequest
- type RootProviderResponse
- type Rule
- type RuleConfigRequest
- type RuleConfigResponse
- type RuleObject
- type Variable
- type VariableValidation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct { Name string Expr []byte ExprRange hcl.Range Range hcl.Range NameRange hcl.Range }
Attribute is an intermediate representation of hcl.Attribute.
type AttributesRequest ¶
AttributesRequest is a request to the server-side Attributes method.
type AttributesResponse ¶
AttributesResponse is a response to the server-side Attributes method.
type Backend ¶ added in v0.3.0
type Backend struct { Type string Config []byte ConfigRange hcl.Range TypeRange hcl.Range DeclRange hcl.Range }
Backend is an intermediate representation of terraform.Backend.
type BackendRequest ¶ added in v0.3.0
type BackendRequest struct{}
BackendRequest is a request to the server-side Backend method.
type BackendResponse ¶ added in v0.3.0
BackendResponse is a response to the server-side Backend method.
type Block ¶
type Block struct { Type string Labels []string Body []byte BodyRange hcl.Range DefRange hcl.Range TypeRange hcl.Range LabelRanges []hcl.Range }
Block is an intermediate representation of hcl.Block.
type BlocksRequest ¶
BlocksRequest is a request to the server-side Blocks method.
type BlocksResponse ¶
BlocksResponse is a response to the server-side Blocks method.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an RPC client for plugins.
func (*Client) Backend ¶ added in v0.3.0
Backend calls the server-side Backend method and returns the backend configuration.
func (*Client) Config ¶ added in v0.5.0
Config calls the server-side Config method and returns the Terraform configuration.
func (*Client) DecodeRuleConfig ¶ added in v0.7.0
DecodeRuleConfig calls the server-side RuleConfig method and reflects the response in the passed argument.
func (*Client) EmitIssue ¶
EmitIssue calls the server-side EmitIssue method with the passed rule and range. You should use EmitIssueOnExpr if you want to emit an issue for an expression. This API provides a lower level interface.
func (*Client) EmitIssueOnExpr ¶
EmitIssueOnExpr calls the server-side EmitIssue method with the passed expression.
func (*Client) EnsureNoError ¶
EnsureNoError is a helper for error handling. Depending on the type of error generated by EvaluateExpr, determine whether to exit, skip, or continue. If it is continued, the passed function will be executed.
func (*Client) EvaluateExpr ¶
EvaluateExpr calls the server-side EvalExpr method and reflects the response in the passed argument.
func (*Client) EvaluateExprOnRootCtx ¶ added in v0.7.0
func (c *Client) EvaluateExprOnRootCtx(expr hcl.Expression, ret interface{}, wantType *cty.Type) error
EvaluateExprOnRootCtx calls the server-side EvalExprOnRootCtx method and reflects the response in the passed argument.
func (*Client) File ¶ added in v0.7.0
File calls the server-side File method and returns the hcl.File object.
func (*Client) Files ¶ added in v0.9.0
Files calls the server-side Files method and returns a collection of hcl.File object.
func (*Client) IsNullExpr ¶ added in v0.7.0
func (c *Client) IsNullExpr(expr hcl.Expression) (bool, error)
IsNullExpr calls the server-side IsNullExpr method with the passed expression.
func (*Client) RootProvider ¶ added in v0.7.0
RootProvider calls the server-side RootProvider method and returns the provider configuration.
func (*Client) WalkModuleCalls ¶ added in v0.4.0
func (c *Client) WalkModuleCalls(walker func(*configs.ModuleCall) error) error
WalkModuleCalls calls the server-side ModuleCalls method and passed the decode response to the passed function.
func (*Client) WalkResourceAttributes ¶
func (c *Client) WalkResourceAttributes(resource, attributeName string, walker func(*hcl.Attribute) error) error
WalkResourceAttributes calls the server-side Attributes method and passes the decoded response to the passed function.
type Config ¶ added in v0.5.0
type Config struct { Path addrs.Module Module *Module CallRange hcl.Range SourceAddr string SourceAddrRange hcl.Range Version string }
Config is an intermediate representation of configs.Config.
type ConfigRequest ¶ added in v0.5.0
type ConfigRequest struct{}
ConfigRequest is a request to the server-side Config method.
type ConfigResponse ¶ added in v0.5.0
ConfigResponse is a response to the server-side Config method.
type Connection ¶
Connection is an intermediate representation of terraform.Connection.
type EmitIssueRequest ¶
type EmitIssueRequest struct { Rule *Rule Message string Location hcl.Range Expr []byte ExprRange hcl.Range }
EmitIssueRequest is a request to the server-side EmitIssue method.
type EvalExprRequest ¶
EvalExprRequest is a request to the server-side EvalExpr method.
type EvalExprResponse ¶
EvalExprResponse is a response to the server-side EvalExpr method.
type FileRequest ¶ added in v0.7.0
type FileRequest struct {
Filename string
}
FileRequest is a request to the server-side File method.
type FileResponse ¶ added in v0.7.0
FileResponse is a response to the server-side File method.
type FilesRequest ¶ added in v0.9.0
type FilesRequest struct{}
FilesRequest is a request to the server-side Files method.
type FilesResponse ¶ added in v0.9.0
FilesResponse is a response to the server-side Files method.
type IsNullExprRequest ¶ added in v0.7.0
IsNullExprRequest is a request to the server-side IsNullExpr method.
type IsNullExprResponse ¶ added in v0.7.0
IsNullExprResponse is a response to the server-side IsNullExpr method.
type ManagedResource ¶
type ManagedResource struct { Connection *Connection Provisioners []*Provisioner CreateBeforeDestroy bool PreventDestroy bool IgnoreAllChanges bool CreateBeforeDestroySet bool PreventDestroySet bool }
ManagedResource is an intermediate representation of terraform.ManagedResource.
type Module ¶ added in v0.5.0
type Module struct { SourceDir string CoreVersionConstraints []string CoreVersionConstraintRanges []hcl.Range ActiveExperiments experiments.Set Backend *Backend ProviderConfigs map[string]*Provider ProviderRequirements *RequiredProviders ProviderLocalNames map[addrs.Provider]string ProviderMetas map[addrs.Provider]*ProviderMeta Variables map[string]*Variable Locals map[string]*Local Outputs map[string]*Output ModuleCalls map[string]*ModuleCall ManagedResources map[string]*Resource DataResources map[string]*Resource }
Module is an intermediate representation of configs.Module.
type ModuleCall ¶ added in v0.4.0
type ModuleCall struct { Name string SourceAddr string SourceAddrRange hcl.Range SourceSet bool Version string VersionRange hcl.Range Config []byte ConfigRange hcl.Range Count []byte CountRange hcl.Range ForEach []byte ForEachRange hcl.Range Providers []PassedProviderConfig DeclRange hcl.Range }
ModuleCall is an intermediate representation of terraform.ModuleCall.
type ModuleCallsRequest ¶ added in v0.4.0
type ModuleCallsRequest struct{}
ModuleCallsRequest is a request to the server-side ModuleCalls method.
type ModuleCallsResponse ¶ added in v0.4.0
type ModuleCallsResponse struct { ModuleCalls []*ModuleCall Err error }
ModuleCallsResponse is a response to the server-side ModuleCalls method.
type Output ¶ added in v0.5.0
type Output struct { Name string Description string Expr []byte ExprRange hcl.Range // DependsOn []hcl.Traversal Sensitive bool DescriptionSet bool SensitiveSet bool DeclRange hcl.Range }
Output is an intermediate representation of configs.Output.
type PassedProviderConfig ¶ added in v0.4.0
type PassedProviderConfig struct { InChild *configs.ProviderConfigRef InParent *configs.ProviderConfigRef }
PassedProviderConfig is an intermediate representation of terraform.PassedProviderConfig.
type Provider ¶ added in v0.5.0
type Provider struct { Name string NameRange hcl.Range Alias string AliasRange *hcl.Range // nil if no alias set Version string VersionRange hcl.Range Config []byte ConfigRange hcl.Range DeclRange hcl.Range }
Provider is an intermediate representation of configs.Provider.
type ProviderMeta ¶ added in v0.5.0
type ProviderMeta struct { Provider string Config []byte ConfigRange hcl.Range ProviderRange hcl.Range DeclRange hcl.Range }
ProviderMeta is an intermediate representation of configs.ProviderMeta.
type Provisioner ¶
type Provisioner struct { Type string Config []byte ConfigRange hcl.Range Connection *Connection When configs.ProvisionerWhen OnFailure configs.ProvisionerOnFailure DeclRange hcl.Range TypeRange hcl.Range }
Provisioner is an intermediate representation of terraform.Provisioner.
type RequiredProvider ¶ added in v0.5.0
type RequiredProvider struct { Name string Source string Type addrs.Provider Requirement string RequirementRange hcl.Range DeclRange hcl.Range }
RequiredProvider is an intermediate representation of configs.RequiredProvider.
type RequiredProviders ¶ added in v0.5.0
type RequiredProviders struct { RequiredProviders map[string]*RequiredProvider DeclRange hcl.Range }
RequiredProviders is an intermediate representation of configs.RequiredProviders.
type Resource ¶
type Resource struct { Mode addrs.ResourceMode Name string Type string Config []byte ConfigRange hcl.Range Count []byte CountRange hcl.Range ForEach []byte ForEachRange hcl.Range ProviderConfigRef *configs.ProviderConfigRef Provider addrs.Provider Managed *ManagedResource DeclRange hcl.Range TypeRange hcl.Range }
Resource is an intermediate representation of terraform.Resource.
type ResourcesRequest ¶
type ResourcesRequest struct {
Name string
}
ResourcesRequest is a request to the server-side Resources method.
type ResourcesResponse ¶
ResourcesResponse is a response to the server-side Resources method.
type RootProviderRequest ¶ added in v0.7.0
type RootProviderRequest struct {
Name string
}
RootProviderRequest is a request to the server-side RootProvider method.
type RootProviderResponse ¶ added in v0.7.0
RootProviderResponse is a response to the server-side RootProvider method.
type Rule ¶
type Rule struct {
Data *RuleObject
}
Rule is an intermediate representation of tflint.Rule.
type RuleConfigRequest ¶ added in v0.7.0
type RuleConfigRequest struct {
Name string
}
RuleConfigRequest is a request to the server-side RuleConfig method.
type RuleConfigResponse ¶ added in v0.7.0
RuleConfigResponse is a response to the server-side RuleConfig method.
type RuleObject ¶
RuleObject holds the data that Rule needs to satisfy the Rule interface.
type Variable ¶ added in v0.5.0
type Variable struct { Name string Description string Default []byte Type []byte ParsingMode configs.VariableParsingMode Validations []*VariableValidation Sensitive bool DescriptionSet bool SensitiveSet bool DeclRange hcl.Range }
Variable is an intermediate representation of configs.Variable.