executor

package
v1.7.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const (
	Executor_Execute_FullMethodName  = "/executor.Executor/Execute"
	Executor_Metadata_FullMethodName = "/executor.Executor/Metadata"
	Executor_Help_FullMethodName     = "/executor.Executor/Help"
)
View Source
const ProtocolVersion = 2

ProtocolVersion is the version that must match between Botkube core and Botkube plugins. This should be bumped whenever a change happens in one or the other that makes it so that they can't safely communicate. This could be adding a new interface value, it could be how helper/schema computes diffs, etc.

NOTE: In the future we can consider using VersionedPlugins. These can be used to negotiate a compatible version between client and server. If this is set, Handshake.ProtocolVersion is not required.

Variables

View Source
var Executor_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "executor.Executor",
	HandlerType: (*ExecutorServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Execute",
			Handler:    _Executor_Execute_Handler,
		},
		{
			MethodName: "Metadata",
			Handler:    _Executor_Metadata_Handler,
		},
		{
			MethodName: "Help",
			Handler:    _Executor_Help_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "executor.proto",
}

Executor_ServiceDesc is the grpc.ServiceDesc for Executor service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_executor_proto protoreflect.FileDescriptor

Functions

func RegisterExecutorServer

func RegisterExecutorServer(s grpc.ServiceRegistrar, srv ExecutorServer)

func Serve

func Serve(p map[string]plugin.Plugin)

Serve serves given plugins.

Types

type Config

type Config struct {

	// rawYAML contains the Executor configuration in YAML definitions.
	RawYAML []byte `protobuf:"bytes,1,opt,name=rawYAML,proto3" json:"rawYAML,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetRawYAML

func (x *Config) GetRawYAML() []byte

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type Dependency added in v0.18.0

type Dependency struct {

	// urls is the map of URL of the dependency. The key is in format of "os/arch", such as "linux/amd64".
	Urls map[string]string `` /* 149-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*Dependency) Descriptor deprecated added in v0.18.0

func (*Dependency) Descriptor() ([]byte, []int)

Deprecated: Use Dependency.ProtoReflect.Descriptor instead.

func (*Dependency) GetUrls added in v0.18.0

func (x *Dependency) GetUrls() map[string]string

func (*Dependency) ProtoMessage added in v0.18.0

func (*Dependency) ProtoMessage()

func (*Dependency) ProtoReflect added in v0.18.0

func (x *Dependency) ProtoReflect() protoreflect.Message

func (*Dependency) Reset added in v0.18.0

func (x *Dependency) Reset()

func (*Dependency) SetUrls added in v0.18.0

func (d *Dependency) SetUrls(in map[string]string)

SetUrls sets the urls map for the dependency.

This method is needed because of current Go limitation: > The Go compiler does not support accessing a struct field x.f where x is of type parameter type even if all types in the type parameter's type set have a field f. We may remove this restriction in a future release. See https://go.dev/doc/go1.18 and https://github.com/golang/go/issues/48522

func (*Dependency) String added in v0.18.0

func (x *Dependency) String() string

type ExecuteContext added in v1.0.0

type ExecuteContext struct {
	IsInteractivitySupported bool            `protobuf:"varint,1,opt,name=isInteractivitySupported,proto3" json:"isInteractivitySupported,omitempty"`
	SlackState               []byte          `protobuf:"bytes,2,opt,name=slackState,proto3" json:"slackState,omitempty"`
	KubeConfig               []byte          `protobuf:"bytes,3,opt,name=kubeConfig,proto3" json:"kubeConfig,omitempty"`
	Message                  *MessageContext `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ExecuteContext) Descriptor deprecated added in v1.0.0

func (*ExecuteContext) Descriptor() ([]byte, []int)

Deprecated: Use ExecuteContext.ProtoReflect.Descriptor instead.

func (*ExecuteContext) GetIsInteractivitySupported added in v1.0.0

func (x *ExecuteContext) GetIsInteractivitySupported() bool

func (*ExecuteContext) GetKubeConfig added in v1.0.0

func (x *ExecuteContext) GetKubeConfig() []byte

func (*ExecuteContext) GetMessage added in v1.6.0

func (x *ExecuteContext) GetMessage() *MessageContext

func (*ExecuteContext) GetSlackState added in v1.0.0

func (x *ExecuteContext) GetSlackState() []byte

func (*ExecuteContext) ProtoMessage added in v1.0.0

func (*ExecuteContext) ProtoMessage()

func (*ExecuteContext) ProtoReflect added in v1.0.0

func (x *ExecuteContext) ProtoReflect() protoreflect.Message

func (*ExecuteContext) Reset added in v1.0.0

func (x *ExecuteContext) Reset()

func (*ExecuteContext) String added in v1.0.0

func (x *ExecuteContext) String() string

type ExecuteInput

type ExecuteInput struct {
	// Context holds execution context.
	Context ExecuteInputContext
	// Command holds the command to be executed.
	Command string
	// Configs is a list of Executor configurations specified by users.
	Configs []*Config
}

ExecuteInput holds the input of the Execute function.

type ExecuteInputContext added in v1.0.0

type ExecuteInputContext struct {
	// IsInteractivitySupported is set to true only if communication platform supports interactive Messages.
	IsInteractivitySupported bool

	// KubeConfig is the slice of byte representation of kubeconfig file content
	KubeConfig []byte

	// SlackState represents modal state. It's available only if:
	//  - IsInteractivitySupported is set to true,
	//  - and interactive actions were used in the response Message.
	// This is an alpha feature and may change in the future.
	// Most likely, it will be generalized to support all communication platforms.
	SlackState *slack.BlockActionStates

	// Message details that triggered a given Executor.
	// Limitations:
	//   - It's available only for SocketSlack. In the future, it may be adopted across other platforms.
	Message Message
}

ExecuteInputContext holds execution context.

type ExecuteOutput

type ExecuteOutput struct {
	// Message represents the output of processing a given input command.
	// You can construct a complex message or just use one of our helper functions:
	//   - api.NewCodeBlockMessage("body", true)
	//   - api.NewPlaintextMessage("body", true)
	Message api.Message
	// Messages holds a collection of messages that should be dispatched to the user in the context of a given command execution.
	// To avoid spamming, you can specify max 15 messages.
	// Limitations:
	//   - It's available only for SocketSlack. In the future, it may be adopted across other platforms.
	//   - Message filtering is not available.
	Messages []api.Message
}

ExecuteOutput holds the output of the Execute function.

type ExecuteRequest

type ExecuteRequest struct {

	// command represents the exact command that was specified by the user.
	Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
	// configs is a list of Executor configurations specified by users.
	Configs []*Config `protobuf:"bytes,2,rep,name=configs,proto3" json:"configs,omitempty"`
	// context holds context execution.
	Context *ExecuteContext `protobuf:"bytes,3,opt,name=context,proto3" json:"context,omitempty"`
	// contains filtered or unexported fields
}

func (*ExecuteRequest) Descriptor deprecated

func (*ExecuteRequest) Descriptor() ([]byte, []int)

Deprecated: Use ExecuteRequest.ProtoReflect.Descriptor instead.

func (*ExecuteRequest) GetCommand

func (x *ExecuteRequest) GetCommand() string

func (*ExecuteRequest) GetConfigs

func (x *ExecuteRequest) GetConfigs() []*Config

func (*ExecuteRequest) GetContext added in v1.0.0

func (x *ExecuteRequest) GetContext() *ExecuteContext

func (*ExecuteRequest) ProtoMessage

func (*ExecuteRequest) ProtoMessage()

func (*ExecuteRequest) ProtoReflect

func (x *ExecuteRequest) ProtoReflect() protoreflect.Message

func (*ExecuteRequest) Reset

func (x *ExecuteRequest) Reset()

func (*ExecuteRequest) String

func (x *ExecuteRequest) String() string

type ExecuteResponse

type ExecuteResponse struct {
	Message  []byte   `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Messages [][]byte `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"`
	// contains filtered or unexported fields
}

func (*ExecuteResponse) Descriptor deprecated

func (*ExecuteResponse) Descriptor() ([]byte, []int)

Deprecated: Use ExecuteResponse.ProtoReflect.Descriptor instead.

func (*ExecuteResponse) GetMessage added in v1.0.0

func (x *ExecuteResponse) GetMessage() []byte

func (*ExecuteResponse) GetMessages added in v1.6.0

func (x *ExecuteResponse) GetMessages() [][]byte

func (*ExecuteResponse) ProtoMessage

func (*ExecuteResponse) ProtoMessage()

func (*ExecuteResponse) ProtoReflect

func (x *ExecuteResponse) ProtoReflect() protoreflect.Message

func (*ExecuteResponse) Reset

func (x *ExecuteResponse) Reset()

func (*ExecuteResponse) String

func (x *ExecuteResponse) String() string

type Executor

type Executor interface {
	Execute(context.Context, ExecuteInput) (ExecuteOutput, error)
	Metadata(ctx context.Context) (api.MetadataOutput, error)
	Help(context.Context) (api.Message, error)
}

Executor defines the Botkube executor plugin functionality.

type ExecutorClient

type ExecutorClient interface {
	Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (*ExecuteResponse, error)
	Metadata(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*MetadataResponse, error)
	Help(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*HelpResponse, error)
}

ExecutorClient is the client API for Executor service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewExecutorClient

func NewExecutorClient(cc grpc.ClientConnInterface) ExecutorClient

type ExecutorServer

type ExecutorServer interface {
	Execute(context.Context, *ExecuteRequest) (*ExecuteResponse, error)
	Metadata(context.Context, *emptypb.Empty) (*MetadataResponse, error)
	Help(context.Context, *emptypb.Empty) (*HelpResponse, error)
	// contains filtered or unexported methods
}

ExecutorServer is the server API for Executor service. All implementations must embed UnimplementedExecutorServer for forward compatibility

type HelpResponse added in v0.18.0

type HelpResponse struct {
	Help []byte `protobuf:"bytes,1,opt,name=help,proto3" json:"help,omitempty"`
	// contains filtered or unexported fields
}

func (*HelpResponse) Descriptor deprecated added in v0.18.0

func (*HelpResponse) Descriptor() ([]byte, []int)

Deprecated: Use HelpResponse.ProtoReflect.Descriptor instead.

func (*HelpResponse) GetHelp added in v0.18.0

func (x *HelpResponse) GetHelp() []byte

func (*HelpResponse) ProtoMessage added in v0.18.0

func (*HelpResponse) ProtoMessage()

func (*HelpResponse) ProtoReflect added in v0.18.0

func (x *HelpResponse) ProtoReflect() protoreflect.Message

func (*HelpResponse) Reset added in v0.18.0

func (x *HelpResponse) Reset()

func (*HelpResponse) String added in v0.18.0

func (x *HelpResponse) String() string

type JSONSchema added in v0.18.0

type JSONSchema struct {

	// value is the string value of the JSON schema.
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	// ref_url is the remote reference of the JSON schema.
	RefUrl string `protobuf:"bytes,2,opt,name=ref_url,json=refUrl,proto3" json:"ref_url,omitempty"`
	// contains filtered or unexported fields
}

func (*JSONSchema) Descriptor deprecated added in v0.18.0

func (*JSONSchema) Descriptor() ([]byte, []int)

Deprecated: Use JSONSchema.ProtoReflect.Descriptor instead.

func (*JSONSchema) GetRefUrl added in v0.18.0

func (x *JSONSchema) GetRefUrl() string

func (*JSONSchema) GetValue added in v0.18.0

func (x *JSONSchema) GetValue() string

func (*JSONSchema) ProtoMessage added in v0.18.0

func (*JSONSchema) ProtoMessage()

func (*JSONSchema) ProtoReflect added in v0.18.0

func (x *JSONSchema) ProtoReflect() protoreflect.Message

func (*JSONSchema) Reset added in v0.18.0

func (x *JSONSchema) Reset()

func (*JSONSchema) String added in v0.18.0

func (x *JSONSchema) String() string

type Message added in v1.6.0

type Message struct {
	Text string
	URL  string
	User User
}

Message holds information about the message that triggered a given Executor.

type MessageContext added in v1.6.0

type MessageContext struct {
	Text string       `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	Url  string       `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
	User *UserContext `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

func (*MessageContext) Descriptor deprecated added in v1.6.0

func (*MessageContext) Descriptor() ([]byte, []int)

Deprecated: Use MessageContext.ProtoReflect.Descriptor instead.

func (*MessageContext) GetText added in v1.6.0

func (x *MessageContext) GetText() string

func (*MessageContext) GetUrl added in v1.6.0

func (x *MessageContext) GetUrl() string

func (*MessageContext) GetUser added in v1.6.0

func (x *MessageContext) GetUser() *UserContext

func (*MessageContext) ProtoMessage added in v1.6.0

func (*MessageContext) ProtoMessage()

func (*MessageContext) ProtoReflect added in v1.6.0

func (x *MessageContext) ProtoReflect() protoreflect.Message

func (*MessageContext) Reset added in v1.6.0

func (x *MessageContext) Reset()

func (*MessageContext) String added in v1.6.0

func (x *MessageContext) String() string

type MetadataResponse

type MetadataResponse struct {

	// version is a version of a given plugin. It should follow the SemVer syntax.
	Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	// description is a description of a given plugin.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// json_schema is a JSON schema of a given plugin.
	JsonSchema *JSONSchema `protobuf:"bytes,3,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"`
	// dependencies is a list of dependencies of a given plugin.
	Dependencies map[string]*Dependency `` /* 165-byte string literal not displayed */
	// URL to plugin documentation.
	DocumentationUrl string `protobuf:"bytes,5,opt,name=documentation_url,json=documentationUrl,proto3" json:"documentation_url,omitempty"`
	// contains filtered or unexported fields
}

func (*MetadataResponse) Descriptor deprecated

func (*MetadataResponse) Descriptor() ([]byte, []int)

Deprecated: Use MetadataResponse.ProtoReflect.Descriptor instead.

func (*MetadataResponse) GetDependencies added in v0.18.0

func (x *MetadataResponse) GetDependencies() map[string]*Dependency

func (*MetadataResponse) GetDescription

func (x *MetadataResponse) GetDescription() string

func (*MetadataResponse) GetDocumentationUrl added in v1.7.0

func (x *MetadataResponse) GetDocumentationUrl() string

func (*MetadataResponse) GetJsonSchema added in v0.18.0

func (x *MetadataResponse) GetJsonSchema() *JSONSchema

func (*MetadataResponse) GetVersion

func (x *MetadataResponse) GetVersion() string

func (*MetadataResponse) ProtoMessage

func (*MetadataResponse) ProtoMessage()

func (*MetadataResponse) ProtoReflect

func (x *MetadataResponse) ProtoReflect() protoreflect.Message

func (*MetadataResponse) Reset

func (x *MetadataResponse) Reset()

func (*MetadataResponse) String

func (x *MetadataResponse) String() string

type Plugin

type Plugin struct {
	// The GRPC plugin must still implement the Plugin interface.
	plugin.NetRPCUnsupportedPlugin

	// Executor represents a concrete implementation that handles the business logic.
	Executor Executor
}

Plugin This is the implementation of plugin.GRPCPlugin, so we can serve and consume different Botkube Executors.

func (*Plugin) GRPCClient

func (p *Plugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient returns the interface implementation for the plugin that is serving via gRPC by GRPCServer.

func (*Plugin) GRPCServer

func (p *Plugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers plugin for serving with the given GRPCServer.

type UnimplementedExecutorServer

type UnimplementedExecutorServer struct {
}

UnimplementedExecutorServer must be embedded to have forward compatible implementations.

func (UnimplementedExecutorServer) Execute

func (UnimplementedExecutorServer) Help added in v0.18.0

func (UnimplementedExecutorServer) Metadata

type UnsafeExecutorServer

type UnsafeExecutorServer interface {
	// contains filtered or unexported methods
}

UnsafeExecutorServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ExecutorServer will result in compilation errors.

type User added in v1.6.0

type User struct {
	// ID represents users identifier.
	Mention string
	// DisplayName represents user display name. It can be empty.
	DisplayName string
}

User represents the user that sent a message.

type UserContext added in v1.6.0

type UserContext struct {
	Mention     string `protobuf:"bytes,1,opt,name=mention,proto3" json:"mention,omitempty"`
	DisplayName string `protobuf:"bytes,2,opt,name=displayName,proto3" json:"displayName,omitempty"`
	// contains filtered or unexported fields
}

func (*UserContext) Descriptor deprecated added in v1.6.0

func (*UserContext) Descriptor() ([]byte, []int)

Deprecated: Use UserContext.ProtoReflect.Descriptor instead.

func (*UserContext) GetDisplayName added in v1.6.0

func (x *UserContext) GetDisplayName() string

func (*UserContext) GetMention added in v1.6.0

func (x *UserContext) GetMention() string

func (*UserContext) ProtoMessage added in v1.6.0

func (*UserContext) ProtoMessage()

func (*UserContext) ProtoReflect added in v1.6.0

func (x *UserContext) ProtoReflect() protoreflect.Message

func (*UserContext) Reset added in v1.6.0

func (x *UserContext) Reset()

func (*UserContext) String added in v1.6.0

func (x *UserContext) String() string

Jump to

Keyboard shortcuts

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