Documentation ¶
Overview ¶
Package plugin implements ignite plugin management. An ignite plugin is a binary which communicates with the ignite binary via RPC thanks to the github.com/hashicorp/go-plugin library.
Index ¶
- Constants
- Variables
- func HandshakeConfig() hplugin.HandshakeConfig
- func NewGRPC(impl Interface) hplugin.Plugin
- func Scaffold(ctx context.Context, dir, appName string, sharedHost bool) (string, error)
- func Update(plugins ...*Plugin) error
- type APIOption
- type AppInfo
- type AppsConfig
- type ChainInfo
- type Chainer
- type ClientAPI
- type Command
- type ExecutedCommand
- type ExecutedHook
- type Flag
- type FlagType
- type Flags
- func (f Flags) GetBool(key string) (bool, error)
- func (f Flags) GetInt(key string) (int, error)
- func (f Flags) GetInt64(key string) (int64, error)
- func (f Flags) GetString(key string) (string, error)
- func (f Flags) GetStringSlice(key string) ([]string, error)
- func (f Flags) GetUint(key string) (uint, error)
- func (f Flags) GetUint64(key string) (uint64, error)
- type Hook
- type Interface
- type Manifest
- type Option
- type Plugin
Constants ¶
const ( FlagTypeString = v1.Flag_TYPE_FLAG_STRING_UNSPECIFIED FlagTypeInt = v1.Flag_TYPE_FLAG_INT FlagTypeUint = v1.Flag_TYPE_FLAG_UINT FlagTypeInt64 = v1.Flag_TYPE_FLAG_INT64 FlagTypeUint64 = v1.Flag_TYPE_FLAG_UINT64 FlagTypeBool = v1.Flag_TYPE_FLAG_BOOL FlagTypeStringSlice = v1.Flag_TYPE_FLAG_STRING_SLICE )
Flag type aliases.
Variables ¶
var ( // ErrFlagNotFound error key flag not found. ErrFlagNotFound = errors.New("flag not found") // ErrInvalidFlagType error invalid flag type. ErrInvalidFlagType = errors.New("invalid flag type") // ErrFlagAssertion error flag type assertion failed. ErrFlagAssertion = errors.New("flag type assertion failed") )
var ErrAppChainNotFound = errors.New("blockchain app not found")
ErrAppChainNotFound indicates that the plugin command is not running inside a blockchain app.
var PluginsPath = xfilepath.Mkdir(xfilepath.Join( config.DirPath, xfilepath.Path("apps"), ))
PluginsPath holds the plugin cache directory.
Functions ¶
func HandshakeConfig ¶
func HandshakeConfig() hplugin.HandshakeConfig
HandshakeConfig are used to just do a basic handshake between a plugin and host. If the handshake fails, a user friendly error is shown. This prevents users from executing bad plugins or executing a plugin directory. It is a UX feature, not a security feature.
Types ¶
type APIOption ¶ added in v28.1.0
type APIOption func(*apiOptions)
APIOption defines options for the client API.
type AppInfo ¶ added in v28.2.0
AppInfo is the structure of app info in app.ignite.yml file which only holds the description and the relative path of the app.
type AppsConfig ¶ added in v28.2.0
AppsConfig is the structure of app.ignite.yml file.
type Chainer ¶
type Chainer interface { // AppPath returns the configured App's path. AppPath() string // ID returns the configured App's chain id. ID() (string, error) // ConfigPath returns the path to the App's config file. ConfigPath() string // RPCPublicAddress returns the configured App's rpc endpoint. RPCPublicAddress() (string, error) // Home returns the App's home dir. Home() (string, error) }
type ClientAPI ¶
type ClientAPI interface { // GetChainInfo returns basic info for the configured blockchain app. GetChainInfo(context.Context) (*ChainInfo, error) }
ClientAPI defines the interface for plugins to get chain app code analysis info.
func NewClientAPI ¶
NewClientAPI creates a new app ClientAPI.
type ExecutedCommand ¶
type ExecutedCommand = v1.ExecutedCommand
Type aliases for the current plugin version.
type ExecutedHook ¶
type ExecutedHook = v1.ExecutedHook
Type aliases for the current plugin version.
type Flags ¶ added in v28.5.1
type Flags []*Flag
Flags represents a slice of Flag pointers.
func (Flags) GetBool ¶ added in v28.5.1
GetBool retrieves the boolean value of the flag with the specified key.
func (Flags) GetInt ¶ added in v28.5.1
GetInt retrieves the integer value of the flag with the specified key.
func (Flags) GetInt64 ¶ added in v28.5.1
GetInt64 retrieves the int64 value of the flag with the specified key.
func (Flags) GetString ¶ added in v28.5.1
GetString retrieves the string value of the flag with the specified key.
func (Flags) GetStringSlice ¶ added in v28.5.1
GetStringSlice retrieves the string slice value of the flag with the specified key.
type Interface ¶
type Interface interface { // Manifest declares the app's Command(s) and Hook(s). Manifest(context.Context) (*Manifest, error) // Execute will be invoked by ignite when an app Command is executed. // It is global for all commands declared in Manifest, if you have declared // multiple commands, use cmd.Path to distinguish them. // The clientAPI argument can be used by plugins to get chain app analysis info. Execute(context.Context, *ExecutedCommand, ClientAPI) error // ExecuteHookPre is invoked by ignite when a command specified by the Hook // path is invoked. // It is global for all hooks declared in Manifest, if you have declared // multiple hooks, use hook.Name to distinguish them. // The clientAPI argument can be used by plugins to get chain app analysis info. ExecuteHookPre(context.Context, *ExecutedHook, ClientAPI) error // ExecuteHookPost is invoked by ignite when a command specified by the hook // path is invoked. // It is global for all hooks declared in Manifest, if you have declared // multiple hooks, use hook.Name to distinguish them. // The clientAPI argument can be used by plugins to get chain app analysis info. ExecuteHookPost(context.Context, *ExecutedHook, ClientAPI) error // ExecuteHookCleanUp is invoked by ignite when a command specified by the // hook path is invoked. Unlike ExecuteHookPost, it is invoked regardless of // execution status of the command and hooks. // It is global for all hooks declared in Manifest, if you have declared // multiple hooks, use hook.Name to distinguish them. // The clientAPI argument can be used by plugins to get chain app analysis info. ExecuteHookCleanUp(context.Context, *ExecutedHook, ClientAPI) error }
Interface defines the interface that all Ignite App must implement.
type Option ¶
type Option func(*Plugin)
Option configures Plugin.
func CollectEvents ¶
CollectEvents collects events from the chain.
func RedirectStdout ¶ added in v28.2.0
type Plugin ¶
type Plugin struct { // Embed the plugin configuration. pluginsconfig.Plugin // Interface allows to communicate with the plugin via RPC. Interface Interface // If any error occurred during the plugin load, it's stored here. Error error // contains filtered or unexported fields }
Plugin represents a ignite plugin.
func Load ¶
func Load(ctx context.Context, plugins []pluginsconfig.Plugin, options ...Option) ([]*Plugin, error)
Load loads the plugins found in the chain config.
There's 2 kinds of plugins, local or remote. Local plugins have their path starting with a `/`, while remote plugins don't. Local plugins are useful for development purpose. Remote plugins require to be fetched first, in $HOME/.ignite/apps folder, then they are loaded from there.
If an error occurs during a plugin load, it's not returned but rather stored in the `Plugin.Error` field. This prevents the loading of other plugins to be interrupted.
func (*Plugin) KillClient ¶
func (p *Plugin) KillClient()
KillClient kills the running plugin client.