client

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2021 License: MPL-2.0 Imports: 18 Imported by: 0

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

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

type AttributesRequest struct {
	Resource      string
	AttributeName string
}

AttributesRequest is a request to the server-side Attributes method.

type AttributesResponse

type AttributesResponse struct {
	Attributes []*Attribute
	Err        error
}

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

type BackendResponse struct {
	Backend *Backend
	Err     error
}

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

type BlocksRequest struct {
	Resource  string
	BlockType string
}

BlocksRequest is a request to the server-side Blocks method.

type BlocksResponse

type BlocksResponse struct {
	Blocks []*Block
	Err    error
}

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 NewClient

func NewClient(conn net.Conn) *Client

NewClient returns a new Client.

func (*Client) Backend

func (c *Client) Backend() (*configs.Backend, error)

Backend calls the server-side Backend method and returns the backend configuration.

func (*Client) Config

func (c *Client) Config() (*configs.Config, error)

Config calls the server-side Config method and returns the Terraform configuration.

func (*Client) DecodeRuleConfig

func (c *Client) DecodeRuleConfig(name string, ret interface{}) error

DecodeRuleConfig calls the server-side RuleConfig method and reflects the response in the passed argument.

func (*Client) EmitIssue

func (c *Client) EmitIssue(rule tflint.Rule, message string, location hcl.Range) error

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

func (c *Client) EmitIssueOnExpr(rule tflint.Rule, message string, expr hcl.Expression) error

EmitIssueOnExpr calls the server-side EmitIssue method with the passed expression.

func (*Client) EnsureNoError

func (*Client) EnsureNoError(err error, proc func() error) error

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

func (c *Client) EvaluateExpr(expr hcl.Expression, ret interface{}, wantType *cty.Type) error

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) File

func (c *Client) File(filename string) (*hcl.File, error)

File calls the server-side File method and returns the hcl.File object.

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

func (c *Client) RootProvider(name string) (*configs.Provider, error)

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.

func (*Client) WalkResourceBlocks

func (c *Client) WalkResourceBlocks(resource, blockType string, walker func(*hcl.Block) error) error

WalkResourceBlocks calls the server-side Blocks method and passes the decoded response to the passed function.

func (*Client) WalkResources

func (c *Client) WalkResources(resource string, walker func(*configs.Resource) error) error

WalkResources calls the server-side Resources 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

type ConfigResponse struct {
	Config *Config
	Err    error
}

ConfigResponse is a response to the server-side Config method.

type Connection

type Connection struct {
	Config      []byte
	ConfigRange hcl.Range

	DeclRange hcl.Range
}

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

type EvalExprRequest struct {
	Expr      []byte
	ExprRange hcl.Range
	Type      cty.Type
	Ret       interface{}
}

EvalExprRequest is a request to the server-side EvalExpr method.

type EvalExprResponse

type EvalExprResponse struct {
	Val cty.Value
	Err error
}

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

type FileResponse struct {
	Bytes []byte
	Range hcl.Range
}

FileResponse is a response to the server-side File method.

type IsNullExprRequest

type IsNullExprRequest struct {
	Expr  []byte
	Range hcl.Range
}

IsNullExprRequest is a request to the server-side IsNullExpr method.

type IsNullExprResponse

type IsNullExprResponse struct {
	Ret bool
	Err error
}

IsNullExprResponse is a response to the server-side IsNullExpr method.

type Local

type Local struct {
	Name      string
	Expr      []byte
	ExprRange hcl.Range

	DeclRange hcl.Range
}

Local is an intermediate representation of configs.Local.

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

type ResourcesResponse struct {
	Resources []*Resource
	Err       error
}

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

type RootProviderResponse struct {
	Provider *Provider
	Err      error
}

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.

func (*Rule) Enabled

func (r *Rule) Enabled() bool

Enabled is a reference method to internal data.

func (r *Rule) Link() string

Link is a reference method to internal data.

func (*Rule) Name

func (r *Rule) Name() string

Name is a reference method to internal data.

func (*Rule) Severity

func (r *Rule) Severity() string

Severity is a reference method to internal data.

type RuleConfigRequest

type RuleConfigRequest struct {
	Name string
}

RuleConfigRequest is a request to the server-side RuleConfig method.

type RuleConfigResponse

type RuleConfigResponse struct {
	Exists bool
	Config []byte
	Range  hcl.Range
	Err    error
}

RuleConfigResponse is a response to the server-side RuleConfig method.

type RuleObject

type RuleObject struct {
	Name     string
	Enabled  bool
	Severity string
	Link     string
}

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.

type VariableValidation

type VariableValidation struct {
	Condition      []byte
	ConditionRange hcl.Range

	ErrorMessage string

	DeclRange hcl.Range
}

VariableValidation is an intermediate representation of configs.VariableValidation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL