Documentation ¶
Index ¶
- Variables
- func CleanupAllClients()
- func FetchRemoteResource(url string) ([]byte, error)
- func GetBinaryExtension() string
- func IsPluginCommand(cmd *cobra.Command) bool
- func RefreshPluginManifest(ctx context.Context, config config.IConfig, fs afero.Fs, baseURL string) error
- type CLIPluginGRPC
- type CLIPluginV1
- type Dispatcher
- type DispatcherGRPC
- type DispatcherRPCServer
- type GRPCClient
- type GRPCServer
- type Plugin
- func (p *Plugin) Install(ctx context.Context, cfg config.IConfig, fs afero.Fs, version string, ...) error
- func (p *Plugin) LookUpLatestVersion() string
- func (p *Plugin) Run(ctx context.Context, config *config.Config, fs afero.Fs, args []string) error
- func (p *Plugin) Uninstall(ctx context.Context, config config.IConfig, fs afero.Fs) error
- type PluginClient
- type PluginList
- type Release
- type TestConfig
- type TestServers
Constants ¶
This section is empty.
Variables ¶
var ( PluginDev = false PluginsPath string )
dev mode vars
Functions ¶
func CleanupAllClients ¶ added in v1.8.1
func CleanupAllClients()
CleanupAllClients tears down and disconnects all "managed" plugin clients
func FetchRemoteResource ¶
FetchRemoteResource returns the remote resource body
func GetBinaryExtension ¶ added in v1.8.6
func GetBinaryExtension() string
GetBinaryExtension returns the appropriate file extension for plugin binary
func IsPluginCommand ¶ added in v1.8.2
IsPluginCommand returns true if the command invoked is for a plugin false otherwise
Types ¶
type CLIPluginGRPC ¶ added in v1.13.8
type CLIPluginGRPC struct { // GRPCPlugin must still implement the Plugin interface hcplugin.Plugin // Concrete implementation, written in Go. This is only used for plugins // that are written in Go. Impl DispatcherGRPC }
CLIPluginGRPC is the implementation of plugin.GRPCPlugin so we can serve/consume this.
func (*CLIPluginGRPC) GRPCClient ¶ added in v1.13.8
func (p *CLIPluginGRPC) GRPCClient(ctx context.Context, broker *hcplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient creates the GRPC client.
func (*CLIPluginGRPC) GRPCServer ¶ added in v1.13.8
func (p *CLIPluginGRPC) GRPCServer(broker *hcplugin.GRPCBroker, s *grpc.Server) error
GRPCServer creates the GRPC server.
type CLIPluginV1 ¶
type CLIPluginV1 struct { // Impl Injection Impl Dispatcher }
CLIPluginV1 is the implementation of plugin.Plugin so we can serve/consume this
This has two methods: Server must return an RPC server for this plugin type. We construct a DispatcherRPCServer for this.
Client must return an implementation of our interface that communicates over an RPC client. We return a PluginClient for this.
Ignore MuxBroker. That is used to create more multiplexed streams on a plugin connection and is a more advanced use case.
type Dispatcher ¶
Dispatcher is the interface that we're exposing as a plugin. It is named so because it is able to dispatch a command from the main CLI to the plugin
type DispatcherGRPC ¶ added in v1.13.8
type DispatcherGRPC interface {
RunCommand(additionalInfo *proto.AdditionalInfo, args []string) error
}
DispatcherGRPC is the interface that's implemented by the plugin and used by the host.
type DispatcherRPCServer ¶
type DispatcherRPCServer struct { // This is the real implementation Impl Dispatcher }
DispatcherRPCServer is the RPC server that a plugin talks to, conforming to the requirements of net/rpc
func (*DispatcherRPCServer) RunCommand ¶
func (s *DispatcherRPCServer) RunCommand(args []string, resp *string) error
RunCommand is the main entry command that can be invoked remotely by the Stripe CLI it is defined here on the plugin's RPC server then we call the internal RunCommand method finally, we then return the response back via the DispatcherRPC interface that the CLI is interacting with
type GRPCClient ¶ added in v1.13.8
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient is an implementation of the gRPC client that talks over gRPC.
func (*GRPCClient) RunCommand ¶ added in v1.13.8
func (m *GRPCClient) RunCommand(additionalInfo *proto.AdditionalInfo, args []string) error
RunCommand calls the RPC.
type GRPCServer ¶ added in v1.13.8
type GRPCServer struct { proto.MainServer // This is the real implementation Impl DispatcherGRPC }
GRPCServer is the gRPC server that GRPCClient talks to.
func (*GRPCServer) RunCommand ¶ added in v1.13.8
func (m *GRPCServer) RunCommand(ctx context.Context, req *proto.RunCommandRequest) (*proto.RunCommandResponse, error)
RunCommand takes the incoming RPC request and calls the real implementation.
type Plugin ¶
type Plugin struct { Shortname string `toml:"Shortname"` Shortdesc string `toml:"Shortdesc"` Binary string `toml:"Binary"` Releases []Release `toml:"Release"` MagicCookieValue string `toml:"MagicCookieValue"` }
Plugin contains the plugin properties
func LookUpPlugin ¶
func LookUpPlugin(ctx context.Context, config config.IConfig, fs afero.Fs, pluginName string) (Plugin, error)
LookUpPlugin returns the matching plugin object
func (*Plugin) Install ¶
func (p *Plugin) Install(ctx context.Context, cfg config.IConfig, fs afero.Fs, version string, baseURL string) error
Install installs the plugin of the given version
func (*Plugin) LookUpLatestVersion ¶
LookUpLatestVersion gets latest CLI version note: assumes versions are listed in asc order
type PluginClient ¶
type PluginClient struct {
// contains filtered or unexported fields
}
PluginClient is an implementation that talks over RPC
func (*PluginClient) RunCommand ¶
func (g *PluginClient) RunCommand(args []string) (string, error)
RunCommand is the main plugin command that can be invoked remotely by the Stripe CLI we expose the command here for the CLI to call, which then calls the method directly on the RPCServer
type PluginList ¶
type PluginList struct {
Plugins []Plugin `toml:"Plugin"`
}
PluginList contains a list of plugins
func GetPluginList ¶
GetPluginList builds a list of allowed plugins to be installed and run by the CLI
type Release ¶
type Release struct { Arch string `toml:"Arch"` OS string `toml:"OS"` Version string `toml:"Version"` Sum string `toml:"Sum"` }
Release is the type that holds release data for a specific build of a plugin
type TestConfig ¶
TestConfig Implementations out several methods
func (*TestConfig) GetConfigFolder ¶
func (c *TestConfig) GetConfigFolder(xdgPath string) string
GetConfigFolder returns the absolute path for the TestConfig
func (*TestConfig) GetInstalledPlugins ¶ added in v1.9.0
func (c *TestConfig) GetInstalledPlugins() []string
GetInstalledPlugins returns the mocked out list of installed plugins
func (*TestConfig) InitConfig ¶
func (c *TestConfig) InitConfig()
InitConfig initializes the config with the values we need
func (*TestConfig) WriteConfigField ¶ added in v1.9.0
func (c *TestConfig) WriteConfigField(field string, value interface{}) error
WriteConfigField mocks out the method so that we can ensure installed plugins data is written
type TestServers ¶
TestServers is a struct containing test servers that will be useful for unit testing plugin logic
func (*TestServers) CloseAll ¶
func (ts *TestServers) CloseAll()
CloseAll calls Close() on each of the httptest servers.