plugin
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package plugin contains the implementations needed to makethe built binary act as a plugin.
A plugin is implemented as an RPC server and the host actsas the client, sending analysis requests to the plugin.Note that the server-client relationship here is the opposite ofthe communication that takes place during the checking phase.
Implementation details are hidden in go-plugin. This package isessentially a wrapper for go-plugin.
Usage¶
A simple plugin can look like this:
package mainimport ( _ "embed" //nolint "github.com/terraform-docs/terraform-docs/plugin" "github.com/terraform-docs/terraform-docs/print" "github.com/terraform-docs/terraform-docs/template" "github.com/terraform-docs/terraform-docs/terraform")func main() { plugin.Serve(&plugin.ServeOpts{ Name: "template", Version: "0.1.0", Printer: printerFunc, })}//go:embed sections.tmplvar tplCustom []byte// printerFunc the function being executed by the plugin client.func printerFunc(config *print.Config, module *terraform.Module) (string, error) { tpl := template.New(config, &template.Item{Name: "custom", Text: string(tplCustom)}, ) rendered, err := tpl.Render("custom", module) if err != nil { return "", err } return rendered, nil}
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcNewClient¶
func NewClient(opts *ClientOpts) *goplugin.Client
NewClient is a wrapper of plugin.NewClient.
Types¶
typeClient¶
type Client struct {// contains filtered or unexported fields}
Client is an RPC Client for the host.
func (*Client)Execute¶
func (c *Client) Execute(args *ExecuteArgs) (string,error)
Execute calls the server-side Execute method and returns generated output.
typeClientOpts¶
ClientOpts is an option for initializing a Client.
typeExecuteArgs¶
ExecuteArgs is the collection of arguments being sent by terraform-docscore while executing the plugin command.