Documentation ¶
Index ¶
- Variables
- func Plugins(opts ...Option) map[int]plugin.PluginSet
- type Base
- type BaseClient
- func (b *BaseClient) Addr() net.Addr
- func (b *BaseClient) AppendMappers(mappers ...*argmapper.Func)
- func (b *BaseClient) CallDynamicFunc(f interface{}, expectedType interface{}, callArgs ...argmapper.Arg) (interface{}, error)
- func (b *BaseClient) Close() error
- func (b *BaseClient) GRPCBroker() *plugin.GRPCBroker
- func (b *BaseClient) GenerateContext(ctx context.Context) (context.Context, context.CancelFunc)
- func (b *BaseClient) GenerateFunc(spec *vagrant_plugin_sdk.FuncSpec, cbFn interface{}, args ...argmapper.Arg) interface{}
- func (b *BaseClient) GetParentComponent() interface{}
- func (b *BaseClient) PluginName() (name string, err error)
- func (b *BaseClient) Seed(args *core.Seeds) error
- func (b *BaseClient) Seeds() (*core.Seeds, error)
- func (b *BaseClient) SetAddr(t net.Addr)
- func (b *BaseClient) SetParentComponent(c interface{})
- func (b *BaseClient) SetPluginName(name string) (err error)
- func (b *BaseClient) SetRequestMetadata(key, value string)
- type BasePlugin
- type BaseServer
- func (b *BaseServer) CallDynamicFunc(f interface{}, expectedType interface{}, args funcspec.Args, ...) (interface{}, error)
- func (b *BaseServer) GenerateSpec(fn interface{}, args ...argmapper.Arg) (*vagrant_plugin_sdk.FuncSpec, error)
- func (b *BaseServer) PluginName(ctx context.Context, _ *emptypb.Empty) (*vagrant_plugin_sdk.PluginInfo_Name, error)
- func (b *BaseServer) Seed(ctx context.Context, seeds *vagrant_plugin_sdk.Args_Seeds) (*emptypb.Empty, error)
- func (b *BaseServer) Seeds(ctx context.Context, _ *emptypb.Empty) (*vagrant_plugin_sdk.Args_Seeds, error)
- func (b *BaseServer) SetPluginName(ctx context.Context, name *vagrant_plugin_sdk.PluginInfo_Name) (*emptypb.Empty, error)
- type CommandPlugin
- type CommunicatorPlugin
- type ConfigPlugin
- type DownloaderPlugin
- type GuestPlugin
- type HostPlugin
- type MapperClient
- type MapperPlugin
- type NamedPluginClient
- type Option
- type PluginInfoPlugin
- type ProviderPlugin
- type ProvisionerPlugin
- type PushPlugin
- type SeederClient
- type SyncedFolderPlugin
Constants ¶
This section is empty.
Variables ¶
var Handshake = plugin.HandshakeConfig{
MagicCookieKey: "VAGRANT_PLUGIN",
MagicCookieValue: "1cf2a7e8cbbd6cec9ec78b952860dc65a7a9eae433b815bea3257bff2257b3a7",
}
Handshake is a common handshake that is shared by plugin and host.
var MapperFns []*argmapper.Func
var ( // ProtomapperAllMap is a set of all the protomapper mappers so // that we can easily filter them in ListMappers. ProtomapperAllMap = map[reflect.Type]struct{}{} )
Functions ¶
Types ¶
type Base ¶
type Base struct { Broker *plugin.GRPCBroker Logger hclog.Logger Mappers []*argmapper.Func Cleanup cleanup.Cleanup Cache cacher.Cache Wrapped bool }
Base contains shared logic for all plugin server/client implementations. This should be embedded in every plugin server/client implementation using the specialized server and client types.
func (*Base) Internal ¶
func (b *Base) Internal() pluginargs.Internal
internal returns a new pluginargs.Internal that can be used with dynamic calls. The Internal structure is an internal-only argument that is used to perform cleanup.
func (*Base) Map ¶
func (b *Base) Map( resultValue, expectedType interface{}, args ...argmapper.Arg, ) (interface{}, error)
Map a value to the expected type using registered mappers NOTE: The expected type must be a pointer, so an expected type of `*int` means an `int` is wanted. Expected type of `**int` means an `*int` is wanted, etc.
func (*Base) Wrap ¶
func (b *Base) Wrap() *BasePlugin
Create a new BasePlugin that is a shallow copy of the current Base and marks wrapped as true. This is used when wrapping a GRPC client.
type BaseClient ¶
type BaseClient struct { *Base Ctx context.Context // base context for the client Client interface{} // actual grpc client // contains filtered or unexported fields }
Base client type
func (*BaseClient) Addr ¶
func (b *BaseClient) Addr() net.Addr
Provides the direct addr being used by this client.
func (*BaseClient) AppendMappers ¶
func (b *BaseClient) AppendMappers(mappers ...*argmapper.Func)
Add extra mapper functions
func (*BaseClient) CallDynamicFunc ¶
func (b *BaseClient) CallDynamicFunc( f interface{}, expectedType interface{}, callArgs ...argmapper.Arg, ) (interface{}, error)
Calls the function provided and converts the result to an expected type. If no type conversion is required, a `false` value for the expectedType will return the raw interface return value. Automatically provided args include hclog.Logger and pluginargs.Internal typed arguments, registered mappers, and a custom logger for argmapper.
NOTE: Provide a `false` value for expectedType if no type conversion is required.
func (*BaseClient) Close ¶
func (b *BaseClient) Close() error
Close the client and perform any required cleanup
func (*BaseClient) GRPCBroker ¶
func (b *BaseClient) GRPCBroker() *plugin.GRPCBroker
Used internally to extract broker
func (*BaseClient) GenerateContext ¶
func (b *BaseClient) GenerateContext(ctx context.Context) (context.Context, context.CancelFunc)
Generates a new context that is a combination of the given context and the client's context. Using the generated context helps to ensure things like customized metadata is included within client requests.
func (*BaseClient) GenerateFunc ¶
func (b *BaseClient) GenerateFunc( spec *vagrant_plugin_sdk.FuncSpec, cbFn interface{}, args ...argmapper.Arg, ) interface{}
Generate a function from a provided spec
func (*BaseClient) GetParentComponent ¶
func (b *BaseClient) GetParentComponent() interface{}
Returns parent component
func (*BaseClient) PluginName ¶
func (b *BaseClient) PluginName() (name string, err error)
Returns the name of the plugin
func (*BaseClient) Seed ¶
func (b *BaseClient) Seed( args *core.Seeds, ) error
Set seed values. These values are will be automatically addeed to all dynamic calls.
func (*BaseClient) Seeds ¶
func (b *BaseClient) Seeds() (*core.Seeds, error)
Returns the collection of stored seed values
func (*BaseClient) SetAddr ¶
func (b *BaseClient) SetAddr(t net.Addr)
Sets a direct addr which can be connected to when passing this client over proto.
func (*BaseClient) SetParentComponent ¶
func (b *BaseClient) SetParentComponent(c interface{})
Sets the parent component
func (*BaseClient) SetPluginName ¶
func (b *BaseClient) SetPluginName(name string) (err error)
Set the plugin name
func (*BaseClient) SetRequestMetadata ¶
func (b *BaseClient) SetRequestMetadata(key, value string)
This is here for internal usage on plugin setup to provide extra information to ruby Based plugins
type BasePlugin ¶
type BasePlugin struct { Cache cacher.Cache // Cache for mappers Cleanup cleanup.Cleanup // Used to register cleanup tasks Mappers []*argmapper.Func // Mappers Logger hclog.Logger // Logger Wrapped bool // Used to determine if wrapper }
BasePlugin contains the information which is common among all plugins. It should be embedded in every plugin type.
func (*BasePlugin) NewClient ¶
func (b *BasePlugin) NewClient( ctx context.Context, broker *plugin.GRPCBroker, s interface{}, ) *BaseClient
Create a new client
func (*BasePlugin) NewServer ¶
func (b *BasePlugin) NewServer( broker *plugin.GRPCBroker, impl interface{}, ) *BaseServer
Create a new server
type BaseServer ¶
type BaseServer struct { *Base // contains filtered or unexported fields }
Base server type
func (*BaseServer) CallDynamicFunc ¶
func (b *BaseServer) CallDynamicFunc( f interface{}, expectedType interface{}, args funcspec.Args, callArgs ...argmapper.Arg, ) (interface{}, error)
Calls the function provided and converts the result to an expected type. If no type conversion is required, a `false` value for the expectedType will return the raw interface return value. Automatically provided args include hclog.Logger and pluginargs.Internal typed arguments, registered mappers, and a custom logger for argmapper.
NOTE: Provide a `false` value for expectedType if no type conversion is required.
func (*BaseServer) GenerateSpec ¶
func (b *BaseServer) GenerateSpec( fn interface{}, args ...argmapper.Arg, ) (*vagrant_plugin_sdk.FuncSpec, error)
Generate a funcspec Based on the provided function
func (*BaseServer) PluginName ¶
func (b *BaseServer) PluginName( ctx context.Context, _ *emptypb.Empty, ) (*vagrant_plugin_sdk.PluginInfo_Name, error)
Returns the plugin name
func (*BaseServer) Seed ¶
func (b *BaseServer) Seed( ctx context.Context, seeds *vagrant_plugin_sdk.Args_Seeds, ) (*emptypb.Empty, error)
Store seed values
func (*BaseServer) Seeds ¶
func (b *BaseServer) Seeds( ctx context.Context, _ *emptypb.Empty, ) (*vagrant_plugin_sdk.Args_Seeds, error)
Returns collection of stored seed values
func (*BaseServer) SetPluginName ¶
func (b *BaseServer) SetPluginName( ctx context.Context, name *vagrant_plugin_sdk.PluginInfo_Name, ) (*emptypb.Empty, error)
Set the plugin name
type CommandPlugin ¶
type CommandPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Command // Impl is the concrete implementation *BasePlugin }
CommandPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Command component type.
func (*CommandPlugin) GRPCClient ¶
func (p *CommandPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*CommandPlugin) GRPCServer ¶
func (p *CommandPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type CommunicatorPlugin ¶
type CommunicatorPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Communicator // Impl is the concrete implementation *BasePlugin }
CommunicatorPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Communicator component type.
func (*CommunicatorPlugin) GRPCClient ¶
func (p *CommunicatorPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*CommunicatorPlugin) GRPCServer ¶
func (p *CommunicatorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type ConfigPlugin ¶
type ConfigPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Config // Impl is the concrete implementation *BasePlugin }
ConfigPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Config component type.
func (*ConfigPlugin) GRPCClient ¶
func (p *ConfigPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*ConfigPlugin) GRPCServer ¶
func (p *ConfigPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type DownloaderPlugin ¶
type DownloaderPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Downloader *BasePlugin }
func (*DownloaderPlugin) GRPCClient ¶
func (p *DownloaderPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*DownloaderPlugin) GRPCServer ¶
func (p *DownloaderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type GuestPlugin ¶
type GuestPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Guest // Impl is the concrete implementation *BasePlugin }
GuestPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Guest component type.
func (*GuestPlugin) GRPCClient ¶
func (p *GuestPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*GuestPlugin) GRPCServer ¶
func (p *GuestPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type HostPlugin ¶
type HostPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Host // Impl is the concrete implementation *BasePlugin }
HostPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Host component type.
func (*HostPlugin) GRPCClient ¶
func (p *HostPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*HostPlugin) GRPCServer ¶
func (p *HostPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type MapperClient ¶
type MapperClient struct { *BaseClient // contains filtered or unexported fields }
MapperClient is an implementation of component.Mapper over gRPC.
func (*MapperClient) Mappers ¶
func (c *MapperClient) Mappers() ([]*argmapper.Func, error)
Mappers returns the list of mappers that are supported by this plugin.
type MapperPlugin ¶
type MapperPlugin struct { plugin.NetRPCUnsupportedPlugin *BasePlugin }
MapperPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Mapper plugin type.
func (*MapperPlugin) GRPCClient ¶
func (p *MapperPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*MapperPlugin) GRPCServer ¶
func (p *MapperPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type NamedPluginClient ¶
type NamedPluginClient interface { SetPluginName(ctx context.Context, in *vagrant_plugin_sdk.PluginInfo_Name, opts ...grpc.CallOption) (*emptypb.Empty, error) PluginName(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*vagrant_plugin_sdk.PluginInfo_Name, error) }
Defines client interface for plugins supporting a name
type Option ¶
type Option func(*pluginConfig)
Option configures Plugins
func WithComponents ¶
func WithComponents(cs ...interface{}) Option
WithComponents sets the components to configure for the plugins. This will append to the components.
func WithLogger ¶
func WithLogger(log hclog.Logger) Option
WithLogger sets the logger for the plugins.
func WithMappers ¶
func WithMappers(ms ...*argmapper.Func) Option
WithMappers sets the mappers to configure for the plugins. This will append to the existing mappers.
type PluginInfoPlugin ¶
type PluginInfoPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.PluginInfo // Impl is the concrete implementation *BasePlugin }
func (*PluginInfoPlugin) GRPCClient ¶
func (p *PluginInfoPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*PluginInfoPlugin) GRPCServer ¶
func (p *PluginInfoPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type ProviderPlugin ¶
type ProviderPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Provider // Impl is the concrete implementation *BasePlugin }
ProviderPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Provider component type.
func (*ProviderPlugin) GRPCClient ¶
func (p *ProviderPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*ProviderPlugin) GRPCServer ¶
func (p *ProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type ProvisionerPlugin ¶
type ProvisionerPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Provisioner // Impl is the concrete implementation *BasePlugin }
ProvisionerPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Provisioner component type.
func (*ProvisionerPlugin) GRPCClient ¶
func (p *ProvisionerPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*ProvisionerPlugin) GRPCServer ¶
func (p *ProvisionerPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type PushPlugin ¶
type PushPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.Push // Impl is the concrete implementation *BasePlugin }
PushPlugin implements plugin.Plugin (specifically GRPCPlugin) for the Push component type.
func (*PushPlugin) GRPCClient ¶
func (p *PushPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*PushPlugin) GRPCServer ¶
func (p *PushPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type SeederClient ¶
type SeederClient interface { Seed(ctx context.Context, in *vagrant_plugin_sdk.Args_Seeds, opts ...grpc.CallOption) (*emptypb.Empty, error) Seeds(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*vagrant_plugin_sdk.Args_Seeds, error) }
Defines client interface for plugins supporting value seeding
type SyncedFolderPlugin ¶
type SyncedFolderPlugin struct { plugin.NetRPCUnsupportedPlugin Impl component.SyncedFolder // Impl is the concrete implementation *BasePlugin }
SyncedFolderPlugin implements plugin.Plugin (specifically GRPCPlugin) for the SyncedFolder component type.
func (*SyncedFolderPlugin) GRPCClient ¶
func (p *SyncedFolderPlugin) GRPCClient( ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn, ) (interface{}, error)
func (*SyncedFolderPlugin) GRPCServer ¶
func (p *SyncedFolderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error