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) 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 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 ¶
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 ¶
type BackendRequest struct{}
BackendRequest is a request to the server-side Backend method.
type BackendResponse ¶
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 ¶
Backend calls the server-side Backend method and returns the backend configuration.
func (*Client) Config ¶
Config calls the server-side Config method and returns the Terraform configuration.
func (*Client) DecodeRuleConfig ¶
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 ¶
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) IsNullExpr ¶
func (c *Client) IsNullExpr(expr hcl.Expression) (bool, error)
IsNullExpr calls the server-side IsNullExpr method with the passed expression.
func (*Client) RootProvider ¶
RootProvider calls the server-side RootProvider method and returns the provider configuration.
func (*Client) WalkModuleCalls ¶
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 ¶
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 ¶
type ConfigRequest struct{}
ConfigRequest is a request to the server-side Config method.
type ConfigResponse ¶
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 ¶
type FileRequest struct {
Filename string
}
FileRequest is a request to the server-side File method.
type FileResponse ¶
FileResponse is a response to the server-side File method.
type IsNullExprRequest ¶
IsNullExprRequest is a request to the server-side IsNullExpr method.
type IsNullExprResponse ¶
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 ¶
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 ¶
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 ¶
type ModuleCallsRequest struct{}
ModuleCallsRequest is a request to the server-side ModuleCalls method.
type ModuleCallsResponse ¶
type ModuleCallsResponse struct { ModuleCalls []*ModuleCall Err error }
ModuleCallsResponse is a response to the server-side ModuleCalls method.
type Output ¶
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 ¶
type PassedProviderConfig struct { InChild *configs.ProviderConfigRef InParent *configs.ProviderConfigRef }
PassedProviderConfig is an intermediate representation of terraform.PassedProviderConfig.
type Provider ¶
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 ¶
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 ¶
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 ¶
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 ¶
type RootProviderRequest struct {
Name string
}
RootProviderRequest is a request to the server-side RootProvider method.
type RootProviderResponse ¶
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 ¶
type RuleConfigRequest struct {
Name string
}
RuleConfigRequest is a request to the server-side RuleConfig method.
type RuleConfigResponse ¶
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 ¶
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.