plugin

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "PREPALERT_PLUGIN_MAGIC_COOKIE",
	MagicCookieValue: "prepalert-grpc-plugin-protocol",
}
View Source
var PluginMap = map[string]plugin.Plugin{
	"provider": &ProviderPlugin{},
}

Functions

func ServePlugin

func ServePlugin(optFns ...func(*serveOption)) error

func WithProviderPlugin

func WithProviderPlugin(impl Provider) func(*serveOption)

Types

type AttributeSchema

type AttributeSchema struct {
	Name     string
	Required bool
}

type BlockSchema

type BlockSchema struct {
	Type         string
	LabelNames   []string
	Unique       bool
	Required     bool
	UniqueLabels bool
	Body         *Schema
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(pluginName string, cmd string, sync bool) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) NewProviderService

func (c *Client) NewProviderService() (Provider, error)

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

func (*GRPCClient) GetQuerySchema

func (m *GRPCClient) GetQuerySchema(ctx context.Context) (*Schema, error)

func (*GRPCClient) RunQuery

func (m *GRPCClient) RunQuery(ctx context.Context, req *RunQueryRequest) (*RunQueryResponse, error)

func (*GRPCClient) ValidateProviderParameter

func (m *GRPCClient) ValidateProviderParameter(ctx context.Context, pp *provider.ProviderParameter) error

type GRPCServer

type GRPCServer struct {
	// This is the real implementation
	Impl Provider
	paproto.UnimplementedProviderServer
}

Here is the gRPC server that GRPCClient talks to.

func (*GRPCServer) RunQuery

type Provider

type Provider interface {
	ValidateProviderParameter(ctx context.Context, pp *provider.ProviderParameter) error
	GetQuerySchema(ctx context.Context) (*Schema, error)
	RunQuery(ctx context.Context, req *RunQueryRequest) (*RunQueryResponse, error)
}

type ProviderPlugin

type ProviderPlugin struct {
	plugin.Plugin
	Impl Provider
}

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 RemoteProvider

type RemoteProvider struct {
	// contains filtered or unexported fields
}

func (*RemoteProvider) NewQuery

func (rp *RemoteProvider) NewQuery(name string, body hcl.Body, evalCtx *hcl.EvalContext) (provider.Query, error)

type RemoteProviderFactory

type RemoteProviderFactory struct {
	// contains filtered or unexported fields
}

func NewRemoteProviderFactory

func NewRemoteProviderFactory(pluginName string, cmd string, sync bool) (*RemoteProviderFactory, func() error, error)

func (*RemoteProviderFactory) NewProvider

type RemoteQuery

type RemoteQuery struct {
	// contains filtered or unexported fields
}

func (*RemoteQuery) Run

func (rq *RemoteQuery) Run(ctx context.Context, evalCtx *hcl.EvalContext) (*provider.QueryResult, error)

type RunQueryRequest

type RunQueryRequest struct {
	ProviderParameters *provider.ProviderParameter
	QueryName          string
	QueryParameters    json.RawMessage
}

type RunQueryResponse

type RunQueryResponse struct {
	Name      string
	Query     string
	Params    []json.RawMessage
	Columns   []string
	Rows      [][]string
	JSONLines []json.RawMessage
}

type Schema

type Schema struct {
	Attributes []AttributeSchema
	Blocks     []BlockSchema
}

func NewSchemaWithProto

func NewSchemaWithProto(s *paproto.Schema) *Schema

func (*Schema) ToProto

func (s *Schema) ToProto() *paproto.Schema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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