Documentation
¶
Overview ¶
Package plugin provides an easy way to create the required CLI for a plugin. It abstracts away all the command line and file parsing so users just need to implement the actual logic.
Package plugin provides an easy way to create the required CLI for a plugin. It abstracts away all the command line and file parsing so users just need to implement the actual logic.
Please see the main BPM-SDK documentation for more details on how to implement a new plugin.
Usage Example:
package main
import (
"github.com/Blockdaemon/bpm-sdk/pkg/plugin"
"github.com/Blockdaemon/bpm-sdk/pkg/node"
"fmt"
)
var pluginVersion string
func start(currentNode node.Node) error {
fmt.Println("Nothing to do here, skipping start")
return nil
}
func main() {
plugin.Initialize(plugin.Plugin{
Name: "empty",
Description: "A plugin that does nothing",
Version: pluginVersion,
Start: start,
CreateSecrets: plugin.DefaultCreateSecrets,
CreateConfigs: plugin.DefaultCreateConfigs
Remove: plugin.DefaultRemove,
Upgrade: plugin.DefaultUpgrade,
})
}
Index ¶
- Constants
- func Initialize(plugin Plugin)
- type DockerPlugin
- func (d DockerPlugin) CreateConfigs(currentNode node.Node) error
- func (d DockerPlugin) CreateSecrets(currentNode node.Node) error
- func (d DockerPlugin) Meta() MetaInfo
- func (d DockerPlugin) Name() string
- func (d DockerPlugin) RemoveConfig(currentNode node.Node) error
- func (d DockerPlugin) RemoveData(currentNode node.Node) error
- func (d DockerPlugin) RemoveRuntime(currentNode node.Node) error
- func (d DockerPlugin) Start(currentNode node.Node) error
- func (d DockerPlugin) Status(currentNode node.Node) (string, error)
- func (d DockerPlugin) Stop(currentNode node.Node) error
- func (d DockerPlugin) Test(currentNode node.Node) (bool, error)
- func (d DockerPlugin) Upgrade(currentNode node.Node) error
- func (d DockerPlugin) ValidateParameters(currentNode node.Node) error
- type MetaInfo
- type Parameter
- type Plugin
Constants ¶
const ( ParameterTypeBool = "bool" ParameterTypeString = "string" SupportsTest = "test" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DockerPlugin ¶
type DockerPlugin struct {
// contains filtered or unexported fields
}
DockerPlugin is a varation of Plugin that comes with default methods for docker
func NewDockerPlugin ¶
func (DockerPlugin) CreateConfigs ¶
func (d DockerPlugin) CreateConfigs(currentNode node.Node) error
CreateConfigs creates configuration files for the blockchain client
func (DockerPlugin) CreateSecrets ¶
func (d DockerPlugin) CreateSecrets(currentNode node.Node) error
CreateSecrets does nothing except printing that it does nothing
func (DockerPlugin) Meta ¶
func (d DockerPlugin) Meta() MetaInfo
func (DockerPlugin) Name ¶
func (d DockerPlugin) Name() string
func (DockerPlugin) RemoveConfig ¶
func (d DockerPlugin) RemoveConfig(currentNode node.Node) error
Removes configuration files related to the node
func (DockerPlugin) RemoveData ¶
func (d DockerPlugin) RemoveData(currentNode node.Node) error
Removes any data (typically the blockchain itself) related to the node
func (DockerPlugin) RemoveRuntime ¶
func (d DockerPlugin) RemoveRuntime(currentNode node.Node) error
Removes the docker network and containers
func (DockerPlugin) Start ¶
func (d DockerPlugin) Start(currentNode node.Node) error
Start starts monitoring agents and delegates to another function to start blockchain containers
func (DockerPlugin) Status ¶
func (d DockerPlugin) Status(currentNode node.Node) (string, error)
DockerStatus returns the status of the running blockchain client and monitoring containers
func (DockerPlugin) Stop ¶
func (d DockerPlugin) Stop(currentNode node.Node) error
DockerStop removes all containers
func (DockerPlugin) Test ¶
func (d DockerPlugin) Test(currentNode node.Node) (bool, error)
Test does nothing except printing that it does nothing
func (DockerPlugin) Upgrade ¶
func (d DockerPlugin) Upgrade(currentNode node.Node) error
The default upgrade strategy removes all containers. If they where running they get started again which will pull new container images.
This works as long as only the container version changes. If the the upgrade needs changes to the configs or migrations tasks it is recommended to overwrite this function
func (DockerPlugin) ValidateParameters ¶
func (d DockerPlugin) ValidateParameters(currentNode node.Node) error
type MetaInfo ¶
type Plugin ¶
type Plugin interface {
// Returns the name of the plugin
Name() string
// Function that creates the secrets for a node
CreateSecrets(currentNode node.Node) error
// Function that creates the configuration for the blockchain client
CreateConfigs(currentNode node.Node) error
// Function to start the node
Start(currentNode node.Node) error
// Function to stop a running node
Stop(currentNode node.Node) error
// Function to return the status (running, incomplete, stopped) of a node
Status(currentNode node.Node) (string, error)
// Function to upgrade a node with a new plugin version
Upgrade(currentNode node.Node) error
// Function to run tests against the node
Test(currentNode node.Node) (bool, error)
// Removes any data (typically the blockchain itself) related to the node
RemoveData(currentNode node.Node) error
// Removes configuration related to the node
RemoveConfig(currentNode node.Node) error
// Removes everything other than data and configuration related to the node
RemoveRuntime(currentNode node.Node) error
// Return plugin meta information such as: What's supported, possible parameters
Meta() MetaInfo
}
Plugin describes and provides the functionality for a plugin