Documentation ¶
Overview ¶
grpc.go hides all the complexity of doing the gRPC calls between the aspect Core and a Plugin implementation by providing simple abstractions from the point of view of Plugin maintainers.
Index ¶
- type AspectPluginFile
- type Base
- func (*Base) BEPEventCallback(*buildeventstream.BuildEvent) error
- func (*Base) CustomCommands() ([]*Command, error)
- func (*Base) PostBuildHook(bool, ioutils.PromptRunner) error
- func (*Base) PostRunHook(bool, ioutils.PromptRunner) error
- func (*Base) PostTestHook(bool, ioutils.PromptRunner) error
- func (*Base) Setup(*SetupConfig) error
- type Command
- type CommandManager
- type CustomCommandFn
- type GRPCClient
- func (m *GRPCClient) BEPEventCallback(event *buildeventstream.BuildEvent) error
- func (m *GRPCClient) CustomCommands() ([]*Command, error)
- func (m *GRPCClient) ExecuteCustomCommand(customCommand string, ctx context.Context, args []string) error
- func (m *GRPCClient) PostBuildHook(isInteractiveMode bool, promptRunner ioutils.PromptRunner) error
- func (m *GRPCClient) PostRunHook(isInteractiveMode bool, promptRunner ioutils.PromptRunner) error
- func (m *GRPCClient) PostTestHook(isInteractiveMode bool, promptRunner ioutils.PromptRunner) error
- func (m *GRPCClient) Setup(config *SetupConfig) error
- type GRPCPlugin
- type GRPCServer
- func (m *GRPCServer) BEPEventCallback(ctx context.Context, req *proto.BEPEventCallbackReq) (*proto.BEPEventCallbackRes, error)
- func (m *GRPCServer) CustomCommands(ctx context.Context, req *proto.CustomCommandsReq) (*proto.CustomCommandsRes, error)
- func (m *GRPCServer) ExecuteCustomCommand(_ context.Context, req *proto.ExecuteCustomCommandReq) (*proto.ExecuteCustomCommandRes, error)
- func (m *GRPCServer) PostBuildHook(ctx context.Context, req *proto.PostBuildHookReq) (*proto.PostBuildHookRes, error)
- func (m *GRPCServer) PostRunHook(ctx context.Context, req *proto.PostRunHookReq) (*proto.PostRunHookRes, error)
- func (m *GRPCServer) PostTestHook(ctx context.Context, req *proto.PostTestHookReq) (*proto.PostTestHookRes, error)
- func (m *GRPCServer) Setup(ctx context.Context, req *proto.SetupReq) (*proto.SetupRes, error)
- type Plugin
- type PluginCommandManager
- type PrompterGRPCClient
- type PrompterGRPCServer
- type SetupConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AspectPluginFile ¶
type AspectPluginFile struct {
Path string
}
AspectPluginFile contains metadata for the aspectplugins file relevant for a plugin.
func NewAspectPluginFile ¶
func NewAspectPluginFile(path string) *AspectPluginFile
NewAspectPluginFile creates a new AspectPluginFile.
type Base ¶
type Base struct{}
Base satisfies the Plugin interface. For plugins that only implement a subset of the Plugin interface, using this as a base will give the advantage of not needing to implement the empty methods.
func (*Base) BEPEventCallback ¶
func (*Base) BEPEventCallback(*buildeventstream.BuildEvent) error
BEPEventCallback satisfies Plugin.BEPEventCallback.
func (*Base) CustomCommands ¶
CustomCommands satisfies Plugin.BEPEventCallback.
func (*Base) PostBuildHook ¶
func (*Base) PostBuildHook(bool, ioutils.PromptRunner) error
PostBuildHook satisfies Plugin.PostBuildHook.
func (*Base) PostRunHook ¶
func (*Base) PostRunHook(bool, ioutils.PromptRunner) error
PostRunHook satisfies Plugin.PostRunHook.
func (*Base) PostTestHook ¶
func (*Base) PostTestHook(bool, ioutils.PromptRunner) error
PostTestHook satisfies Plugin.PostTestHook.
type Command ¶
type Command struct { *proto.Command Run CustomCommandFn }
Command defines the information needed to create a custom command that will be callable when running the CLI.
func NewCommand ¶
func NewCommand( use string, shortDesc string, longDesc string, run CustomCommandFn, ) *Command
NewCommand is a wrapper around Command. Designed to be used as a cleaner way to make a Command given Command's nested proto
type CommandManager ¶
type CommandManager interface { Save(commands []*Command) error Execute(command string, ctx context.Context, args []string) error }
CommandManager is internal to the SDK and is used to manage custom commands that are provided by plugins.
type CustomCommandFn ¶
CustomCommandFn defines the parameters of that the Run functions will be called with.
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient implements the gRPC client that is used by the Core to communicate with the Plugin instances.
func (*GRPCClient) BEPEventCallback ¶
func (m *GRPCClient) BEPEventCallback(event *buildeventstream.BuildEvent) error
BEPEventCallback is called from the Core to execute the Plugin BEPEventCallback.
func (*GRPCClient) CustomCommands ¶
func (m *GRPCClient) CustomCommands() ([]*Command, error)
CustomCommands is called from the Core to execute the Plugin CustomCommands. It returns a list of commands that the plugin implements.
func (*GRPCClient) ExecuteCustomCommand ¶
func (m *GRPCClient) ExecuteCustomCommand(customCommand string, ctx context.Context, args []string) error
ExecuteCustomCommand is called from the Core to execute the sdk ExecuteCustomCommand.
func (*GRPCClient) PostBuildHook ¶
func (m *GRPCClient) PostBuildHook(isInteractiveMode bool, promptRunner ioutils.PromptRunner) error
PostBuildHook is called from the Core to execute the Plugin PostBuildHook. It starts the prompt runner server with the provided PromptRunner.
func (*GRPCClient) PostRunHook ¶
func (m *GRPCClient) PostRunHook(isInteractiveMode bool, promptRunner ioutils.PromptRunner) error
PostRunHook is called from the Core to execute the Plugin PostRunHook. It starts the prompt runner server with the provided PromptRunner.
func (*GRPCClient) PostTestHook ¶
func (m *GRPCClient) PostTestHook(isInteractiveMode bool, promptRunner ioutils.PromptRunner) error
PostTestHook is called from the Core to execute the Plugin PostTestHook. It starts the prompt runner server with the provided PromptRunner.
func (*GRPCClient) Setup ¶
func (m *GRPCClient) Setup(config *SetupConfig) error
Setup is called from the Core to execute the Plugin Setup.
type GRPCPlugin ¶
GRPCPlugin represents a Plugin that communicates over gRPC.
func (*GRPCPlugin) GRPCClient ¶
func (p *GRPCPlugin) GRPCClient(ctx context.Context, broker *goplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient returns a client to perform the RPC calls to the Plugin instance from the Core.
func (*GRPCPlugin) GRPCServer ¶
func (p *GRPCPlugin) GRPCServer(broker *goplugin.GRPCBroker, s *grpc.Server) error
GRPCServer registers an instance of the GRPCServer in the Plugin binary.
type GRPCServer ¶
type GRPCServer struct { Impl Plugin // contains filtered or unexported fields }
GRPCServer implements the gRPC server that runs on the Plugin instances.
func (*GRPCServer) BEPEventCallback ¶
func (m *GRPCServer) BEPEventCallback( ctx context.Context, req *proto.BEPEventCallbackReq, ) (*proto.BEPEventCallbackRes, error)
BEPEventCallback translates the gRPC call to the Plugin BEPEventCallback implementation.
func (*GRPCServer) CustomCommands ¶
func (m *GRPCServer) CustomCommands( ctx context.Context, req *proto.CustomCommandsReq, ) (*proto.CustomCommandsRes, error)
CustomCommands translates the gRPC call to the Plugin CustomCommands implementation. It returns a list of commands that the plugin implements.
func (*GRPCServer) ExecuteCustomCommand ¶
func (m *GRPCServer) ExecuteCustomCommand( _ context.Context, req *proto.ExecuteCustomCommandReq, ) (*proto.ExecuteCustomCommandRes, error)
ExecuteCustomCommand translates the gRPC call to the sdk ExecuteCustomCommand implementation.
func (*GRPCServer) PostBuildHook ¶
func (m *GRPCServer) PostBuildHook( ctx context.Context, req *proto.PostBuildHookReq, ) (*proto.PostBuildHookRes, error)
PostBuildHook translates the gRPC call to the Plugin PostBuildHook implementation. It starts a prompt runner that is passed to the Plugin instance to be able to perform prompt actions to the CLI user.
func (*GRPCServer) PostRunHook ¶
func (m *GRPCServer) PostRunHook( ctx context.Context, req *proto.PostRunHookReq, ) (*proto.PostRunHookRes, error)
PostRunHook translates the gRPC call to the Plugin PostRunHook implementation. It starts a prompt runner that is passed to the Plugin instance to be able to perform prompt actions to the CLI user.
func (*GRPCServer) PostTestHook ¶
func (m *GRPCServer) PostTestHook( ctx context.Context, req *proto.PostTestHookReq, ) (*proto.PostTestHookRes, error)
PostTestHook translates the gRPC call to the Plugin PostTestHook implementation. It starts a prompt runner that is passed to the Plugin instance to be able to perform prompt actions to the CLI user.
type Plugin ¶
type Plugin interface { BEPEventCallback(event *buildeventstream.BuildEvent) error CustomCommands() ([]*Command, error) PostBuildHook( isInteractiveMode bool, promptRunner ioutils.PromptRunner, ) error PostTestHook( isInteractiveMode bool, promptRunner ioutils.PromptRunner, ) error PostRunHook( isInteractiveMode bool, promptRunner ioutils.PromptRunner, ) error Setup(config *SetupConfig) error }
Plugin determines how an aspect Plugin should be implemented.
type PluginCommandManager ¶
type PluginCommandManager struct {
// contains filtered or unexported fields
}
PluginCommandManager is internal to the SDK and is used to manage custom commands that are provided by plugins.
func (*PluginCommandManager) Save ¶
func (cm *PluginCommandManager) Save(commands []*Command) error
Save satisfies CommandManager.
type PrompterGRPCClient ¶
type PrompterGRPCClient struct {
// contains filtered or unexported fields
}
PrompterGRPCClient implements the gRPC client that is used by the Plugin instance to communicate with the Core to request prompt actions from the user.
type PrompterGRPCServer ¶
type PrompterGRPCServer struct {
// contains filtered or unexported fields
}
PrompterGRPCServer implements the gRPC server that runs on the Core and is passed to the Plugin to allow prompt actions to the CLI user.
func (*PrompterGRPCServer) Run ¶
func (p *PrompterGRPCServer) Run( ctx context.Context, req *proto.PromptRunReq, ) (*proto.PromptRunRes, error)
Run translates the gRPC call to perform a prompt Run on the Core.
type SetupConfig ¶
type SetupConfig struct { File *AspectPluginFile Properties []byte }
SetupConfig represents a plugin configuration parsed from the aspectplugins file.
func NewSetupConfig ¶
func NewSetupConfig( file *AspectPluginFile, properties []byte, ) *SetupConfig
NewSetupConfig creates a new SetupConfig.