plugin

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plugin is the SDK for writing orca plugins in Go.

A plugin is a standalone binary named orca-plugin-<name>, placed in one of orca's plugin directories. Its main function only needs to call Serve with an implementation of CommandProvider:

func main() {
	plugin.Serve(&myProvider{})
}

Index

Constants

View Source
const CommandsPluginName = "commands"

CommandsPluginName is the name the CommandProvider is dispensed under.

Variables

View Source
var Handshake = goplugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "ORCA_PLUGIN",
	MagicCookieValue: "4b0a1d6e-2f53-4c4e-9a52-7a1f6c1d2e83",
}

Handshake must match between orca and its plugins. Bump ProtocolVersion on any breaking change to the gRPC protocol.

PluginMap is the set of plugin types orca can dispense from a plugin binary.

Functions

func Serve

func Serve(impl CommandProvider)

Serve starts the plugin's gRPC server and blocks until orca disconnects. It should be the only thing a plugin's main function does.

Types

type CommandProvider

type CommandProvider interface {
	// Commands returns the command tree to register with orca.
	Commands() ([]CommandSpec, error)
	// Execute runs one of the commands returned by Commands. Anything written to
	// stdout/stderr is forwarded to the user's terminal.
	Execute(ctx context.Context, req ExecuteRequest) (exitCode int, err error)
}

CommandProvider is implemented by plugins that contribute CLI commands to orca.

type CommandProviderPlugin

type CommandProviderPlugin struct {
	goplugin.NetRPCUnsupportedPlugin

	Impl CommandProvider
}

CommandProviderPlugin wires a CommandProvider into go-plugin over gRPC. Impl is only set on the plugin side.

func (*CommandProviderPlugin) GRPCClient

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

func (*CommandProviderPlugin) GRPCServer

func (p *CommandProviderPlugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error

type CommandSpec

type CommandSpec struct {
	// Use is the one-line usage message, the first word is the command name.
	Use         string
	Short       string
	Long        string
	Flags       []FlagSpec
	Subcommands []CommandSpec
}

type ExecuteRequest

type ExecuteRequest struct {
	// CommandPath is the names of the commands from the plugin's top-level
	// command down to the one being executed, e.g. ["k8s", "ctx"].
	CommandPath []string
	Args        []string
	// Flags holds every flag value for the command keyed by name, encoded as
	// strings.
	Flags map[string]string
}

type FlagSpec

type FlagSpec struct {
	Name      string
	Shorthand string
	Usage     string
	Type      FlagType
	// Default value, encoded as a string regardless of type, e.g. "true" for a
	// bool flag.
	Default string
}

type FlagType

type FlagType int
const (
	FlagString FlagType = iota
	FlagBool
)

Directories

Path Synopsis
proto
v1

Jump to

Keyboard shortcuts

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