plugins

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "CHAINLOOP_CLI_PLUGIN",
	MagicCookieValue: "chainloop-cli-plugin-v1",
}

Handshake is a common handshake that is shared by CLI plugins and the host.

View Source
var PluginMap = map[string]plugin.Plugin{
	"chainloop": &ChainloopCliPlugin{},
}

PluginMap is the map of plugins.

Functions

func GetPluginsDir

func GetPluginsDir(appName string) string

Types

type ChainloopCliPlugin

type ChainloopCliPlugin struct {
	Impl Plugin
}

ChainloopCliPlugin is the implementation of plugin.Plugin.

func (ChainloopCliPlugin) Client

func (ChainloopCliPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*ChainloopCliPlugin) Server

func (p *ChainloopCliPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type ChainloopConfig

type ChainloopConfig struct {
	ControlPlaneAPI string
	ControlPlaneCA  string
	CASAPI          string
	CASCA           string
	Organization    string
	Token           string
}

type FlagInfo

type FlagInfo struct {
	Name        string
	Shorthand   string
	Description string
	Type        string
	Default     any
	Required    bool
}

FlagInfo describes a command flag.

type LoadedPlugin

type LoadedPlugin struct {
	Path     string
	Plugin   Plugin
	Metadata PluginMetadata
}

LoadedPlugin represents a loaded plugin with its metadata.

type Manager

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

Manager handles loading and managing plugins.

func NewManager

func NewManager(logger *zerolog.Logger) *Manager

NewManager creates a new plugin manager.

func (*Manager) GetAllPlugins

func (m *Manager) GetAllPlugins() map[string]*LoadedPlugin

GetAllPlugins returns all loaded plugins.

func (*Manager) GetPlugin

func (m *Manager) GetPlugin(name string) (*LoadedPlugin, bool)

GetPlugin returns a loaded plugin by name.

func (*Manager) LoadPlugins

func (m *Manager) LoadPlugins(ctx context.Context) error

LoadPlugins loads all plugins from the plugins directory.

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown closes all plugin connections.

type Plugin

type Plugin interface {
	// Exec executes a command within the plugin
	Exec(ctx context.Context, config PluginExecConfig) (*PluginExecResult, error)

	// GetMetadata returns plugin metadata including commands it provides
	GetMetadata(ctx context.Context) (PluginMetadata, error)
}

Plugin is the interface that plugins must implement.

type PluginCommandInfo

type PluginCommandInfo struct {
	Name        string
	Description string
	Usage       string
	Flags       []*FlagInfo
}

PluginCommandInfo describes a command provided by the plugin

type PluginExecConfig

type PluginExecConfig struct {
	Command         string
	Args            []string
	Flags           map[string]*SimpleFlag
	ChainloopConfig ChainloopConfig
}

PluginExecConfig is the configuration for a plugin command execution.

type PluginExecResult

type PluginExecResult struct {
	Output   string
	Error    string
	ExitCode int
}

type PluginMetadata

type PluginMetadata struct {
	Name        string
	Version     string
	Description string
	Commands    []*PluginCommandInfo
}

PluginMetadata contains information about the plugin.

type RPCClient

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

RPCClient is an implementation of Plugin that talks over RPC.

func (*RPCClient) Exec

func (*RPCClient) GetMetadata

func (m *RPCClient) GetMetadata(_ context.Context) (PluginMetadata, error)

type RPCServer

type RPCServer struct {
	Impl Plugin
}

RPCServer is the RPC server that RPCClient talks to, conforming to the requirements of net/rpc.

func (*RPCServer) Exec

func (m *RPCServer) Exec(config PluginExecConfig, resp *PluginExecResult) error

func (*RPCServer) GetMetadata

func (m *RPCServer) GetMetadata(_ any, resp *PluginMetadata) error

type SimpleFlag

type SimpleFlag struct {
	Name        string
	Shorthand   string
	Usage       string
	Value       string
	DefValue    string
	Changed     bool
	NoOptDefVal string
}

Jump to

Keyboard shortcuts

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