{"modulePath":"github.com/chainloop-dev/chainloop","version":"v1.127.3","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package plugins\n\n## Variables\n\n```go\nvar Handshake = plugin.HandshakeConfig{\n\tProtocolVersion:  1,\n\tMagicCookieKey:   \"CHAINLOOP_CLI_PLUGIN\",\n\tMagicCookieValue: \"chainloop-cli-plugin-v1\",\n}\n```\nHandshake is a common handshake that is shared by CLI plugins and the host.\n\n```go\nvar PluginMap = map[string]plugin.Plugin{\n\t\"chainloop\": \u0026ChainloopCliPlugin{},\n}\n```\nPluginMap is the map of plugins.\n\n## Functions\n\n```go\nfunc GetPluginsDir(appName string) string\n```\n\n## Types\n\n```go\ntype ChainloopCliPlugin struct {\n\tImpl Plugin\n}\n```\nChainloopCliPlugin is the implementation of plugin.Plugin.\n\n```go\nfunc (ChainloopCliPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)\n```\n\n```go\nfunc (p *ChainloopCliPlugin) Server(*plugin.MuxBroker) (interface{}, error)\n```\n\n```go\ntype ChainloopConfig struct {\n\tControlPlaneAPI string\n\tControlPlaneCA  string\n\tCASAPI          string\n\tCASCA           string\n\tOrganization    string\n\tToken           string\n}\n```\n\n```go\ntype FlagInfo struct {\n\tName        string\n\tShorthand   string\n\tDescription string\n\tType        string\n\tDefault     any\n\tRequired    bool\n}\n```\nFlagInfo describes a command flag.\n\n```go\ntype LoadedPlugin struct {\n\tPath     string\n\tPlugin   Plugin\n\tMetadata PluginMetadata\n}\n```\nLoadedPlugin represents a loaded plugin with its metadata.\n\n```go\ntype Manager struct {\n\t// contains filtered or unexported fields\n}\n```\nManager handles loading and managing plugins.\n\n```go\nfunc NewManager(logger *zerolog.Logger) *Manager\n```\nNewManager creates a new plugin manager.\n\n```go\nfunc (m *Manager) GetAllPlugins() map[string]*LoadedPlugin\n```\nGetAllPlugins returns all loaded plugins.\n\n```go\nfunc (m *Manager) GetPlugin(name string) (*LoadedPlugin, bool)\n```\nGetPlugin returns a loaded plugin by name.\n\n```go\nfunc (m *Manager) LoadPlugins(ctx context.Context) error\n```\nLoadPlugins loads all plugins from the plugins directory.\n\n```go\nfunc (m *Manager) Shutdown()\n```\nShutdown closes all plugin connections.\n\n```go\ntype PlatformConfig struct {\n\tAPI string\n}\n```\n\n```go\ntype Plugin interface {\n\t// Exec executes a command within the plugin\n\tExec(ctx context.Context, config PluginExecConfig) (*PluginExecResult, error)\n\n\t// GetMetadata returns plugin metadata including commands it provides\n\tGetMetadata(ctx context.Context) (PluginMetadata, error)\n}\n```\nPlugin is the interface that plugins must implement.\n\n```go\ntype PluginCommandInfo struct {\n\tName        string\n\tDescription string\n\tUsage       string\n\tFlags       []*FlagInfo\n\t// Optional: if specified, this command will be added as a subcommand to the parent\n\tParentCommand string\n}\n```\nPluginCommandInfo describes a command provided by the plugin\n\n```go\ntype PluginExecConfig struct {\n\tCommand string\n\t// Optional: the parent command if this is a subcommand\n\tParentCommand   string\n\tArgs            []string\n\tFlags           map[string]*SimpleFlag\n\tChainloopConfig ChainloopConfig\n\tPlatformConfig  PlatformConfig\n}\n```\nPluginExecConfig is the configuration for a plugin command execution.\n\n```go\ntype PluginExecResult struct {\n\tOutput   string\n\tError    string\n\tExitCode int\n}\n```\n\n```go\ntype PluginMetadata struct {\n\tName        string\n\tVersion     string\n\tDescription string\n\tCommands    []*PluginCommandInfo\n}\n```\nPluginMetadata contains information about the plugin.\n\n```go\ntype RPCClient struct {\n\t// contains filtered or unexported fields\n}\n```\nRPCClient is an implementation of Plugin that talks over RPC.\n\n```go\nfunc (m *RPCClient) Exec(_ context.Context, config PluginExecConfig) (*PluginExecResult, error)\n```\n\n```go\nfunc (m *RPCClient) GetMetadata(_ context.Context) (PluginMetadata, error)\n```\n\n```go\ntype RPCServer struct {\n\tImpl Plugin\n}\n```\nRPCServer is the RPC server that RPCClient talks to, conforming to the requirements of net/rpc.\n\n```go\nfunc (m *RPCServer) Exec(config PluginExecConfig, resp *PluginExecResult) error\n```\n\n```go\nfunc (m *RPCServer) GetMetadata(_ any, resp *PluginMetadata) error\n```\n\n```go\ntype SimpleFlag struct {\n\tName        string\n\tShorthand   string\n\tUsage       string\n\tValue       string\n\tDefValue    string\n\tChanged     bool\n\tNoOptDefVal string\n}\n```\n\n","path":"github.com/chainloop-dev/chainloop/app/cli/pkg/plugins","name":"plugins","synopsis":"","isRedistributable":true}
