Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterPluginProviders(registry *provider.Registry, pluginDirs []string) error
- func Serve(impl ProviderPlugin)
- type Client
- func (c *Client) ExecuteProvider(ctx context.Context, providerName string, input map[string]any) (*provider.Output, error)
- func (c *Client) GetProviderDescriptor(ctx context.Context, providerName string) (*provider.Descriptor, error)
- func (c *Client) GetProviders(ctx context.Context) ([]string, error)
- func (c *Client) Kill()
- func (c *Client) Name() string
- func (c *Client) Path() string
- type GRPCClient
- func (c *GRPCClient) ExecuteProvider(ctx context.Context, providerName string, input map[string]any) (*provider.Output, error)
- func (c *GRPCClient) GetProviderDescriptor(ctx context.Context, providerName string) (*provider.Descriptor, error)
- func (c *GRPCClient) GetProviders(ctx context.Context) ([]string, error)
- type GRPCPlugin
- type GRPCServer
- func (s *GRPCServer) ExecuteProvider(ctx context.Context, req *proto.ExecuteProviderRequest) (*proto.ExecuteProviderResponse, error)
- func (s *GRPCServer) GetProviderDescriptor(ctx context.Context, req *proto.GetProviderDescriptorRequest) (*proto.GetProviderDescriptorResponse, error)
- func (s *GRPCServer) GetProviders(ctx context.Context, _ *proto.GetProvidersRequest) (*proto.GetProvidersResponse, error)
- type HandshakeConfigData
- type ProviderPlugin
- type ProviderWrapper
Constants ¶
const (
// PluginName is the name used to identify the provider plugin
PluginName = "provider"
)
Variables ¶
var HandshakeConfig = &HandshakeConfigData{
ProtocolVersion: 1,
MagicCookieKey: "SCAFCTL_PLUGIN",
MagicCookieValue: "scafctl_provider_plugin",
}
HandshakeConfig is used to verify plugin compatibility
Functions ¶
func RegisterPluginProviders ¶
RegisterPluginProviders discovers plugins and registers them with the provider registry
func Serve ¶
func Serve(impl ProviderPlugin)
Serve is a helper function for plugin implementers to serve their plugins This should be called from the plugin's main() function
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a plugin client and manages its lifecycle
func (*Client) ExecuteProvider ¶
func (c *Client) ExecuteProvider(ctx context.Context, providerName string, input map[string]any) (*provider.Output, error)
ExecuteProvider executes a provider with the given input
func (*Client) GetProviderDescriptor ¶
func (c *Client) GetProviderDescriptor(ctx context.Context, providerName string) (*provider.Descriptor, error)
GetProviderDescriptor returns metadata for a specific provider
func (*Client) GetProviders ¶
GetProviders returns all provider names exposed by this plugin
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient implements the gRPC client for the plugin
func (*GRPCClient) ExecuteProvider ¶
func (c *GRPCClient) ExecuteProvider(ctx context.Context, providerName string, input map[string]any) (*provider.Output, error)
ExecuteProvider implements ProviderPlugin.ExecuteProvider
func (*GRPCClient) GetProviderDescriptor ¶
func (c *GRPCClient) GetProviderDescriptor(ctx context.Context, providerName string) (*provider.Descriptor, error)
GetProviderDescriptor implements ProviderPlugin.GetProviderDescriptor
func (*GRPCClient) GetProviders ¶
func (c *GRPCClient) GetProviders(ctx context.Context) ([]string, error)
GetProviders implements ProviderPlugin.GetProviders
type GRPCPlugin ¶
type GRPCPlugin struct {
plugin.Plugin
Impl ProviderPlugin
}
GRPCPlugin implements plugin.GRPCPlugin from hashicorp/go-plugin
func (*GRPCPlugin) GRPCClient ¶
func (p *GRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)
GRPCClient returns the gRPC client
func (*GRPCPlugin) GRPCServer ¶
func (p *GRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
GRPCServer registers the gRPC server
type GRPCServer ¶
type GRPCServer struct {
proto.UnimplementedPluginServiceServer
Impl ProviderPlugin
}
GRPCServer implements the gRPC server for the plugin
func (*GRPCServer) ExecuteProvider ¶
func (s *GRPCServer) ExecuteProvider(ctx context.Context, req *proto.ExecuteProviderRequest) (*proto.ExecuteProviderResponse, error)
ExecuteProvider implements the ExecuteProvider RPC
func (*GRPCServer) GetProviderDescriptor ¶
func (s *GRPCServer) GetProviderDescriptor(ctx context.Context, req *proto.GetProviderDescriptorRequest) (*proto.GetProviderDescriptorResponse, error)
GetProviderDescriptor implements the GetProviderDescriptor RPC
func (*GRPCServer) GetProviders ¶
func (s *GRPCServer) GetProviders(ctx context.Context, _ *proto.GetProvidersRequest) (*proto.GetProvidersResponse, error)
GetProviders implements the GetProviders RPC
type HandshakeConfigData ¶
type HandshakeConfigData struct {
ProtocolVersion uint
MagicCookieKey string
MagicCookieValue string
}
HandshakeConfigData contains the handshake configuration
type ProviderPlugin ¶
type ProviderPlugin interface {
// GetProviders returns all provider names exposed by this plugin
GetProviders(ctx context.Context) ([]string, error)
// GetProviderDescriptor returns metadata for a specific provider
GetProviderDescriptor(ctx context.Context, providerName string) (*provider.Descriptor, error)
// ExecuteProvider executes a provider with the given input
ExecuteProvider(ctx context.Context, providerName string, input map[string]any) (*provider.Output, error)
}
ProviderPlugin is the interface that plugins must implement This wraps the provider.Provider interface for plugin communication
type ProviderWrapper ¶
type ProviderWrapper struct {
// contains filtered or unexported fields
}
ProviderWrapper wraps a plugin provider to implement the provider.Provider interface
func NewProviderWrapper ¶
func NewProviderWrapper(client *Client, providerName string) (*ProviderWrapper, error)
NewProviderWrapper creates a new provider wrapper for a plugin provider
func (*ProviderWrapper) Client ¶
func (w *ProviderWrapper) Client() *Client
Client returns the underlying plugin client
func (*ProviderWrapper) Descriptor ¶
func (w *ProviderWrapper) Descriptor() *provider.Descriptor
Descriptor returns the provider descriptor