client

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: MPL-2.0 Imports: 13 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 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

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 added in v0.3.0

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

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

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{}) error

EvaluateExpr calls the server-side EvalExpr method and reflects the response in the passed argument.

func (*Client) WalkModuleCalls added in v0.4.0

func (c *Client) WalkModuleCalls(walker func(*terraform.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(*terraform.Resource) error) error

WalkResources calls the server-side Resources method and passes the decoded response to the passed function.

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
	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 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 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 PassedProviderConfig added in v0.4.0

type PassedProviderConfig struct {
	InChild  *terraform.ProviderConfigRef
	InParent *terraform.ProviderConfigRef
}

PassedProviderConfig is an intermediate representation of terraform.PassedProviderConfig.

type Provisioner

type Provisioner struct {
	Type        string
	Config      []byte
	ConfigRange hcl.Range
	Connection  *Connection
	When        terraform.ProvisionerWhen
	OnFailure   terraform.ProvisionerOnFailure

	DeclRange hcl.Range
	TypeRange hcl.Range
}

Provisioner is an intermediate representation of terraform.Provisioner.

type Resource

type Resource struct {
	Mode         terraform.ResourceMode
	Name         string
	Type         string
	Config       []byte
	ConfigRange  hcl.Range
	Count        []byte
	CountRange   hcl.Range
	ForEach      []byte
	ForEachRange hcl.Range

	ProviderConfigRef *terraform.ProviderConfigRef

	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 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 RuleObject

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

RuleObject holds the data that Rule needs to satisfy the Rule interface.

Jump to

Keyboard shortcuts

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