Documentation ¶
Index ¶
- Variables
- func NewPluginClient(pluginExecutable string, logger hclog.Logger) (*plugin.Client, error)
- func ServeCommands(version Version, protocol PluginProtocol, commands ...ExportCommand)
- func ToProtoVersion(v Version) *proto.Version
- type CommandInfo
- type ExportCommand
- type ExportPlugin
- type ExportRequest
- type ExportResponse
- type GRPCExportPlugin
- type ImportDirective
- type PluginInformation
- type PluginProtocol
- type RPCExportPlugin
- type Version
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
Types ¶
type CommandInfo ¶
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 ¶
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 ¶
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 FromSemver ¶
func FromSemver(s semver.Version) Version