Documentation
¶
Index ¶
- Variables
- func FetchRemoteResource(url string) ([]byte, error)
- func RefreshPluginManifest(ctx context.Context, config config.IConfig, fs afero.Fs, baseURL string) error
- type CLIPluginV1
- type Dispatcher
- type DispatcherRPCServer
- type Plugin
- type PluginClient
- type PluginList
- type Release
- type TestConfig
- func (c *TestConfig) EditConfig() error
- func (c *TestConfig) GetConfigFolder(xdgPath string) string
- func (c *TestConfig) GetProfile() *config.Profile
- func (c *TestConfig) InitConfig()
- func (c *TestConfig) PrintConfig() error
- func (c *TestConfig) RemoveAllProfiles() error
- func (c *TestConfig) RemoveProfile(profileName string) error
- type TestServers
Constants ¶
This section is empty.
Variables ¶
var ( PluginDev = false PluginsPath string )
dev mode vars
Functions ¶
func FetchRemoteResource ¶
FetchRemoteResource returns the remote resource body
Types ¶
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 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 Plugin ¶
type Plugin struct {
Shortname string
Binary string
Releases []Release `toml:"Release"`
MagicCookieValue string
}
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, config 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 TestConfig ¶
type TestConfig struct{}
TestConfig Implementation out the GetConfigFolder function
func (*TestConfig) EditConfig ¶
func (c *TestConfig) EditConfig() error
EditConfig is not implemented
func (*TestConfig) GetConfigFolder ¶
func (c *TestConfig) GetConfigFolder(xdgPath string) string
GetConfigFolder returns the absolute path for the TestConfig
func (*TestConfig) GetProfile ¶
func (c *TestConfig) GetProfile() *config.Profile
GetProfile returns the Mock Profile
func (*TestConfig) PrintConfig ¶
func (c *TestConfig) PrintConfig() error
PrintConfig is not implemented
func (*TestConfig) RemoveAllProfiles ¶
func (c *TestConfig) RemoveAllProfiles() error
RemoveAllProfiles is not implemented
func (*TestConfig) RemoveProfile ¶
func (c *TestConfig) RemoveProfile(profileName string) error
RemoveProfile is not implemented
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.