plugin

package
v0.4.1-0...-5b560ab Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package plugin contains the implementations needed to make the built binary act as a plugin.

A plugin is implemented as an RPC server and the host acts as the client, sending analysis requests to the plugin. Note that the server-client relationship here is the opposite of the communication that takes place during the checking phase.

Implementation details are hidden in go-plugin. This package is essentially a wrapper for go-plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(opts *ClientOpts) *plugin.Client

NewClient is a wrapper of plugin.NewClient.

func Serve

func Serve(opts *ServeOpts)

Serve is a wrapper of plugin.Serve. This is entrypoint of all plugins.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an RPC client for the host.

func (*Client) ApplyConfig

func (c *Client) ApplyConfig(config *tflint.Config) error

ApplyConfig calls the server-side ApplyConfig method.

func (*Client) Check

func (c *Client) Check(server tfserver.Server) error

Check calls the server-side Check method. At the same time, it starts the server to respond to requests from the plugin side. Note that this server (tfserver.Server) serves clients that satisfy the Runner interface and is different from the server (plugin.Server) that provides the plugin system.

func (*Client) RuleNames

func (c *Client) RuleNames() ([]string, error)

RuleNames calls the server-side RuleNames method and returns the list of names.

func (*Client) RuleSetName

func (c *Client) RuleSetName() (string, error)

RuleSetName calls the server-side RuleSetName method and returns its name.

func (*Client) RuleSetVersion

func (c *Client) RuleSetVersion() (string, error)

RuleSetVersion calls the server-side RuleSetVersion method and returns its version.

type ClientOpts

type ClientOpts struct {
	Cmd *exec.Cmd
}

ClientOpts is an option for initializing a Client.

type RuleSetPlugin

type RuleSetPlugin struct {
	// contains filtered or unexported fields
}

RuleSetPlugin is a wrapper to satisfy the interface of go-plugin.

func (RuleSetPlugin) Client

func (RuleSetPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client returns an RPC client for the host.

func (*RuleSetPlugin) Server

func (p *RuleSetPlugin) Server(b *plugin.MuxBroker) (interface{}, error)

Server returns an RPC server acting as a plugin.

type ServeOpts

type ServeOpts struct {
	RuleSet tflint.RuleSet
}

ServeOpts is an option for serving a plugin. Each plugin can pass a RuleSet that represents its own functionality.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an RPC server acting as a plugin.

func (*Server) ApplyConfig

func (s *Server) ApplyConfig(config *tflint.Config, resp *interface{}) error

ApplyConfig applies the passed config to its own plugin implementation.

func (*Server) Check

func (s *Server) Check(brokerID uint32, resp *interface{}) error

Check calls its own plugin implementation with an RPC client that can send requests to the host process.

func (*Server) RuleNames

func (s *Server) RuleNames(args interface{}, resp *[]string) error

RuleNames returns the list of rule names provided by the plugin.

func (*Server) RuleSetName

func (s *Server) RuleSetName(args interface{}, resp *string) error

RuleSetName returns the name of the plugin.

func (*Server) RuleSetVersion

func (s *Server) RuleSetVersion(args interface{}, resp *string) error

RuleSetVersion returns the version of the plugin.

Jump to

Keyboard shortcuts

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