plugin

package module
v0.0.0-...-781459b Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	MagicCookieKey:   "TF_EXPORTER",
	MagicCookieValue: "exporter-plugin",
}

HandshakeConfig is a struct that the plugin host and author must agree upon for a successful connection

Functions

func NewPluginClient

func NewPluginClient(pluginExecutable string, logger hclog.Logger) (*plugin.Client, error)

NewPluginClient loads a plugin for use. This should only be used by a plugin host, and not a client

func ServeCommands

func ServeCommands(version Version, protocol PluginProtocol, commands ...ExportCommand)

func ToProtoVersion

func ToProtoVersion(v Version) *proto.Version

Types

type CommandInfo

type CommandInfo struct {
	Name        string
	Description string
	Summary     string
	Version     Version
}

type ExportCommand

type ExportCommand interface {
	Export(ExportRequest) (ExportResponse, error)
	Help() (string, error)
	Info() (CommandInfo, error)
}

type ExportPlugin

type ExportPlugin interface {
	// Export accepts arguments from the plugin host with the intention
	// that the plugin will create terraform files for a given resource on
	// the local file system. The method returns a list of resource types, names,
	// and IDs. These will be converted by the plugin host into a shell script
	// that, when executed, will run terraform import on the resources in question
	Export(string, ExportRequest) (ExportResponse, error)
	Help(string) (string, error)
	Info() (PluginInformation, error)
}

ExportPlugin is the interface plugin authors implement

func NewExportPlugin

func NewExportPlugin(version Version, commands ...ExportCommand) ExportPlugin

type ExportRequest

type ExportRequest struct {
	OutputDirectory    string
	SkipProviderOutput bool
	PluginArgs         []string
}

ExportRequest is sent to the plugin to initiate processing. Output files are expected to be written in OutputDirectory, preferably without subdirectories. If SkipProviderOutput is false, a "provider.tf" file should be written that initializes the terraform provider used to manage the newly created files. PluginArgs are a subset of the original command line args and can be considered the equivalent of os.Args[1:] if the program were executed directly

type ExportResponse

type ExportResponse struct {
	Directives []ImportDirective
}

ExportResponse should contain all of the resources that were successfully created in Export

type GRPCExportPlugin

type GRPCExportPlugin struct {
	plugin.Plugin
	Impl ExportPlugin
}

func (*GRPCExportPlugin) GRPCClient

func (p *GRPCExportPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)

func (*GRPCExportPlugin) GRPCServer

func (p *GRPCExportPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error

type ImportDirective

type ImportDirective struct {
	Resource string
	Name     string
	ID       string
}

ImportDirective represents a recently created resource that should be "terraform import"ed into the current state

func (ImportDirective) String

func (i ImportDirective) String() string

Outputs the directive in a format that can be directly appended to a terraform import command line

type PluginInformation

type PluginInformation struct {
	Version  Version       `toml:"version"`
	Provides []CommandInfo `toml:"provides"`
}

PluginInformation represents a plugin. The name is used as the plugin name when referenced on the command line, so it must NOT contain spaces, special characters, or unprintable characters

type PluginProtocol

type PluginProtocol uint8

PluginProtocol is a list of plugin versions supported by the host

const (
	RPCProtocol  PluginProtocol = 2
	GRPCProtocol PluginProtocol = 3
)

type RPCExportPlugin

type RPCExportPlugin struct {
	Impl ExportPlugin
}

func (RPCExportPlugin) Client

func (p RPCExportPlugin) Client(_ *plugin.MuxBroker, client *rpc.Client) (any, error)

func (*RPCExportPlugin) Server

func (p *RPCExportPlugin) Server(*plugin.MuxBroker) (any, error)

type Version

type Version struct {
	Major         uint64 `toml:"major"`
	Minor         uint64 `toml:"minor"`
	Patch         uint64 `toml:"patch"`
	Pre           string `toml:"pre"`
	BuildMetadata string `toml:"meta"`
}

Version represents a semver.org compliant semantic version

func FromProtoVersion

func FromProtoVersion(p *proto.Version) Version

func FromSemver

func FromSemver(s semver.Version) Version

func FromString

func FromString(s string) Version

func (Version) String

func (v Version) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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