Documentation ¶
Overview ¶
Package cmd defines the concrete protocol between host and plugins based on libVeinMind plugin system.
Each plugins by themselves are standalone programs that can be run individually, but they must conform to some protocol between them and their host program if they want to produce meaningful output that can be interpreted and handled.
The plugins' command line layout should form a directory hierarchy with with an info command on the root. The info command reflects callable subcommands in the plugin, providing information and constrains of each subcommands.
Index ¶
- func AddContainerCommand(c *Command, f ContainerHandler)
- func AddContainerIDsCommand(c *Command, f ContainerIDsHandler)
- func AddImageCommand(c *Command, f ImageHandler)
- func AddImageIDsCommand(c *Command, f ImageIDsHandler)
- func AddModeCommand(c *Command, typ string, obj interface{}, f ModeHandler)
- func AddPluginCommand(c *Command, typ string, obj interface{}, f PluginHandler)
- func AddRuntimeCommand(c *Command, f RuntimeHandler)
- func Execute()
- func ExecuteContext(ctx context.Context)
- func ExecuteContextE(ctx context.Context) error
- func ExecuteE() error
- func IncompatibleMode() error
- func RegisterMode(mode Mode)
- func RegisterPartition(f Partitioner)
- func Scan(ctx context.Context, iter plugin.ExecIterator, objs interface{}, ...) error
- func ScanAllContainers(ctx context.Context, rang plugin.ExecRange, runtime []api.Runtime, ...) error
- func ScanAllImages(ctx context.Context, rang plugin.ExecRange, runtime []api.Runtime, ...) error
- func ScanClusters(ctx context.Context, rang plugin.ExecRange, cluster []api.Cluster, ...) error
- func ScanContainer(ctx context.Context, rang plugin.ExecRange, container api.Container, ...) error
- func ScanContainerIDs(ctx context.Context, rang plugin.ExecRange, runtime api.Runtime, ids []string, ...) error
- func ScanContainers(ctx context.Context, rang plugin.ExecRange, containers []api.Container, ...) error
- func ScanIAC(ctx context.Context, rang plugin.ExecRange, IAC iac.IAC, ...) error
- func ScanIACs(ctx context.Context, rang plugin.ExecRange, IACs []iac.IAC, ...) error
- func ScanIDs(ctx context.Context, iter plugin.ExecIterator, obj interface{}, ids []string, ...) error
- func ScanImage(ctx context.Context, rang plugin.ExecRange, image api.Image, ...) error
- func ScanImageIDs(ctx context.Context, rang plugin.ExecRange, runtime api.Runtime, ids []string, ...) error
- func ScanImages(ctx context.Context, rang plugin.ExecRange, images []api.Image, ...) error
- func ScanRuntime(ctx context.Context, rang plugin.ExecRange, runtime api.Runtime, ...) error
- func ScanRuntimes(ctx context.Context, rang plugin.ExecRange, runtimes []api.Runtime, ...) error
- func SetManifest(m plugin.Manifest)
- type ClusterHandler
- type Command
- func MapClusterCommand(c *Command, f ClusterHandler) *Command
- func MapContainerCommand(c *Command, f ContainerHandler) *Command
- func MapContainerIDsCommand(c *Command, f ContainerIDsHandler) *Command
- func MapIACCommand(c *Command, f IACHandler) *Command
- func MapImageCommand(c *Command, f ImageHandler) *Command
- func MapImageIDsCommand(c *Command, f ImageIDsHandler) *Command
- func MapModeCommand(c *Command, typ string, obj interface{}, f ModeHandler) *Command
- func MapPluginCommand(c *Command, typ string, obj interface{}, f PluginHandler) *Command
- func MapRuntimeCommand(c *Command, f RuntimeHandler) *Command
- func NewInfoCommand(m plugin.Manifest) *Command
- type ContainerHandler
- type ContainerIDsHandler
- type IACHandler
- type ImageHandler
- type ImageIDsHandler
- type Index
- func (idx *Index) AddContainerCommand(c *Command, f ContainerHandler)
- func (idx *Index) AddContainerIDsCommand(c *Command, f ContainerIDsHandler)
- func (idx *Index) AddImageCommand(c *Command, f ImageHandler)
- func (idx *Index) AddImageIDsCommand(c *Command, f ImageIDsHandler)
- func (idx *Index) AddModeCommand(c *Command, typ string, obj interface{}, f ModeHandler)
- func (idx *Index) AddPluginCommand(c *Command, typ string, obj interface{}, f PluginHandler)
- func (idx *Index) AddRuntimeCommand(c *Command, f RuntimeHandler)
- func (idx *Index) MapClusterCommand(c *Command, f ClusterHandler) *Command
- func (idx *Index) MapContainerCommand(c *Command, f ContainerHandler) *Command
- func (idx *Index) MapContainerIDsCommand(c *Command, f ContainerIDsHandler) *Command
- func (idx *Index) MapIACCommand(c *Command, f IACHandler) *Command
- func (idx *Index) MapImageCommand(c *Command, f ImageHandler) *Command
- func (idx *Index) MapImageIDsCommand(c *Command, f ImageIDsHandler) *Command
- func (idx *Index) MapModeCommand(c *Command, typ string, obj interface{}, f ModeHandler) *Command
- func (idx *Index) MapPluginCommand(c *Command, typ string, obj interface{}, f PluginHandler) *Command
- func (idx *Index) MapRuntimeCommand(c *Command, f RuntimeHandler) *Command
- func (idx *Index) NewInfoCommand(m plugin.Manifest) *Command
- type Mode
- type ModeHandler
- type Partitioner
- type PluginHandler
- type Root
- type RuntimeHandler
- type UniqueRoot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddContainerCommand ¶ added in v1.2.0
func AddContainerCommand( c *Command, f ContainerHandler, )
AddContainerCommand issues defaultIndex.AddContainerCommand.
func AddContainerIDsCommand ¶ added in v1.2.0
func AddContainerIDsCommand( c *Command, f ContainerIDsHandler, )
AddContainerCommand issues defaultIndex.AddContainerIDsCommand.
func AddImageCommand ¶
func AddImageCommand( c *Command, f ImageHandler, )
AddImageCommand issues defaultIndex.AddImageCommand.
func AddImageIDsCommand ¶ added in v1.1.0
func AddImageIDsCommand( c *Command, f ImageIDsHandler, )
AddImageCommand issues defaultIndex.AddImageIDsCommand.
func AddModeCommand ¶
func AddModeCommand( c *Command, typ string, obj interface{}, f ModeHandler, )
MapModeCommand issues defaultIndex.AddModeCommand.
func AddPluginCommand ¶
func AddPluginCommand( c *Command, typ string, obj interface{}, f PluginHandler, )
AddPluginCommand invokes defaultIndex.AddPluginCommand.
func AddRuntimeCommand ¶
func AddRuntimeCommand( c *Command, f RuntimeHandler, )
AddRuntimeCommand issues defaultIndex.AddRuntimeCommand.
func ExecuteContext ¶
ExecuteContext calls the ExecuteContextE and exits with code on error.
func ExecuteContextE ¶
ExecuteContextE executes the auto-generated main command with context.
func IncompatibleMode ¶
func IncompatibleMode() error
IncompatibleMode is the helper for reporting the user specified mode is not compatible with the command.
func RegisterPartition ¶
func RegisterPartition(f Partitioner)
func Scan ¶
func Scan( ctx context.Context, iter plugin.ExecIterator, objs interface{}, opts ...plugin.ExecOption, ) error
Scan attempt to partition the objects and invoke plugin commands by itering the exec iterator.
func ScanAllContainers ¶ added in v1.2.0
func ScanAllContainers( ctx context.Context, rang plugin.ExecRange, runtime []api.Runtime, opts ...plugin.ExecOption, ) error
ScanAllContainers scans container provided by runtime list.
func ScanAllImages ¶
func ScanAllImages( ctx context.Context, rang plugin.ExecRange, runtime []api.Runtime, opts ...plugin.ExecOption, ) error
ScanAllImages scans image provided by runtime list.
func ScanClusters ¶ added in v1.3.0
func ScanClusters( ctx context.Context, rang plugin.ExecRange, cluster []api.Cluster, opts ...plugin.ExecOption, ) error
ScanClusters scans cluster list.
func ScanContainer ¶ added in v1.2.0
func ScanContainer( ctx context.Context, rang plugin.ExecRange, container api.Container, opts ...plugin.ExecOption, ) error
ScanContainer scan an container provided.
func ScanContainerIDs ¶ added in v1.2.0
func ScanContainerIDs( ctx context.Context, rang plugin.ExecRange, runtime api.Runtime, ids []string, opts ...plugin.ExecOption, ) error
ScanContainerIDs with a runtime and a list of IDs provided.
func ScanContainers ¶ added in v1.2.0
func ScanContainers( ctx context.Context, rang plugin.ExecRange, containers []api.Container, opts ...plugin.ExecOption, ) error
ScanContainers scans container provided by container list.
func ScanIAC ¶ added in v1.3.2
func ScanIAC( ctx context.Context, rang plugin.ExecRange, IAC iac.IAC, opts ...plugin.ExecOption, ) error
ScanIAC scans iac provided by iac.
func ScanIACs ¶ added in v1.3.2
func ScanIACs( ctx context.Context, rang plugin.ExecRange, IACs []iac.IAC, opts ...plugin.ExecOption, ) error
ScanIACs scans iac provided by iac list.
func ScanIDs ¶ added in v1.0.7
func ScanIDs( ctx context.Context, iter plugin.ExecIterator, obj interface{}, ids []string, opts ...plugin.ExecOption, ) error
ScanIDs attempts to load a root object while passing a list of IDs that will be acceptable.
func ScanImage ¶
func ScanImage( ctx context.Context, rang plugin.ExecRange, image api.Image, opts ...plugin.ExecOption, ) error
ScanImage scan an image provided.
func ScanImageIDs ¶ added in v1.0.7
func ScanImageIDs( ctx context.Context, rang plugin.ExecRange, runtime api.Runtime, ids []string, opts ...plugin.ExecOption, ) error
ScanImageIDs with a runtime and a list of IDs provided.
func ScanImages ¶
func ScanImages( ctx context.Context, rang plugin.ExecRange, images []api.Image, opts ...plugin.ExecOption, ) error
ScanImages scans image provided by image list.
func ScanRuntime ¶
func ScanRuntime( ctx context.Context, rang plugin.ExecRange, runtime api.Runtime, opts ...plugin.ExecOption, ) error
ScanRuntime scans a runtime provided.
func ScanRuntimes ¶
func ScanRuntimes( ctx context.Context, rang plugin.ExecRange, runtimes []api.Runtime, opts ...plugin.ExecOption, ) error
ScanRuntimes scans runtime provided by runtime list.
func SetManifest ¶
SetManifest specifies a manifest as default manifest.
The default manifest will only be used in the info command of the auto-generated entrypoint, when calling the Execute or ExecuteContext plugin.
Types ¶
type ClusterHandler ¶ added in v1.3.0
ClusterHandler is the handler for specified cluster.
type Command ¶
Command is libVeinMind plugin command that is built upon the widely used cobra framework.
func MapClusterCommand ¶ added in v1.3.0
func MapClusterCommand( c *Command, f ClusterHandler, ) *Command
MapClusterCommand issues defaultIndex.MapClusterCommand.
func MapContainerCommand ¶ added in v1.2.0
func MapContainerCommand( c *Command, f ContainerHandler, ) *Command
MapContainerCommand issues defaultIndex.MapContainerCommand.
func MapContainerIDsCommand ¶ added in v1.2.0
func MapContainerIDsCommand( c *Command, f ContainerIDsHandler, ) *Command
MapContainerIDsCommand issues defaultIndex.MapContainerIDsCommand.
func MapIACCommand ¶ added in v1.3.2
func MapIACCommand(c *Command, f IACHandler) *Command
func MapImageCommand ¶
func MapImageCommand( c *Command, f ImageHandler, ) *Command
MapImageCommand issues defaultIndex.MapImageCommand.
func MapImageIDsCommand ¶ added in v1.1.0
func MapImageIDsCommand( c *Command, f ImageIDsHandler, ) *Command
MapImageIDsCommand issues defaultIndex.MapImageIDsCommand.
func MapModeCommand ¶
func MapModeCommand( c *Command, typ string, obj interface{}, f ModeHandler, ) *Command
MapModeCommand issues defaultIndex.MapModeCommand.
func MapPluginCommand ¶
func MapPluginCommand( c *Command, typ string, obj interface{}, f PluginHandler, ) *Command
MapPluginCommand issues defaultIndex.MapPluginCommand.
func MapRuntimeCommand ¶
func MapRuntimeCommand( c *Command, f RuntimeHandler, ) *Command
MapRuntimeCommand issues defaultIndex.MapRuntimeCommand.
func NewInfoCommand ¶
NewInfoCommand issues defaultIndex.NewInfoCommand.
type ContainerHandler ¶ added in v1.2.0
ContainerHandler is the handler for specified containers.
type ContainerIDsHandler ¶ added in v1.2.0
ContainerIDsHandler is the handler for current list of containers.
type IACHandler ¶ added in v1.3.2
IACHandler is the handler for specified iac.
type ImageHandler ¶
ImageHandler is the handler for specified images.
type ImageIDsHandler ¶ added in v1.1.0
ImageIDsHandler is the handler for current list of images.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index for mapping user defined commands that is compatible with libVeinMind plugin system into command information.
func (*Index) AddContainerCommand ¶ added in v1.2.0
func (idx *Index) AddContainerCommand( c *Command, f ContainerHandler, )
AddContainerCommand invokes MapContainerCommand with no return.
func (*Index) AddContainerIDsCommand ¶ added in v1.2.0
func (idx *Index) AddContainerIDsCommand( c *Command, f ContainerIDsHandler, )
AddContainerIDsCommand invokes MapContainerCommand with no return.
func (*Index) AddImageCommand ¶
func (idx *Index) AddImageCommand( c *Command, f ImageHandler, )
AddImageCommand invokes MapImageCommand with no return.
func (*Index) AddImageIDsCommand ¶ added in v1.1.0
func (idx *Index) AddImageIDsCommand( c *Command, f ImageIDsHandler, )
AddImageIDsCommand invokes MapImageCommand with no return.
func (*Index) AddModeCommand ¶
func (idx *Index) AddModeCommand( c *Command, typ string, obj interface{}, f ModeHandler, )
AddModeCommand invokes MapModeCommand with no return.
func (*Index) AddPluginCommand ¶
func (idx *Index) AddPluginCommand( c *Command, typ string, obj interface{}, f PluginHandler, )
AddPluginCommand invokes MapPluginCommand with no return.
func (*Index) AddRuntimeCommand ¶
func (idx *Index) AddRuntimeCommand( c *Command, f RuntimeHandler, )
AddRuntimeCommand issues MapRuntimeCommand with no return.
func (*Index) MapClusterCommand ¶ added in v1.3.0
func (idx *Index) MapClusterCommand( c *Command, f ClusterHandler, ) *Command
MapClusterCommand attempts to create a cluster command.
The command will attempt to initialize the cluster object from specified mode with flags, and then invoke the function specified by caller.
func (*Index) MapContainerCommand ¶ added in v1.2.0
func (idx *Index) MapContainerCommand( c *Command, f ContainerHandler, ) *Command
MapContainerCommand attempts to create a container command.
The command will attempt to initialize the runtime object from specified mode with flags, scan and match containers in the runtime, and open matched containers, one at once.
func (*Index) MapContainerIDsCommand ¶ added in v1.2.0
func (idx *Index) MapContainerIDsCommand( c *Command, f ContainerIDsHandler, ) *Command
MapContainerIDsCommand attempts to create an container IDs command.
The command will attempt to initialize the runtime object from specified mode with flags, scan and match containers in the runtime, and collect those qualified container IDs.
func (*Index) MapIACCommand ¶ added in v1.3.2
func (idx *Index) MapIACCommand( c *Command, f IACHandler, ) *Command
MapIACCommand attempts to create a iac command.
func (*Index) MapImageCommand ¶
func (idx *Index) MapImageCommand( c *Command, f ImageHandler, ) *Command
MapImageCommand attempts to create a image command.
The command will attempt to initialize the runtime object from specified mode with flags, scan and match images in the runtime, and open matched images, one at once.
func (*Index) MapImageIDsCommand ¶ added in v1.1.0
func (idx *Index) MapImageIDsCommand( c *Command, f ImageIDsHandler, ) *Command
MapImageIDsCommand attempts to create an image IDs command.
The command will attempt to initialize the runtime object from specified mode with flags, scan and match images in the runtime, and collect those qualified image IDs.
func (*Index) MapModeCommand ¶
func (idx *Index) MapModeCommand( c *Command, typ string, obj interface{}, f ModeHandler, ) *Command
MapModeCommand attempts to create a mode command.
The command will lookup the specified mode, initialize root objects, then invoke the function provided by caller.
func (*Index) MapPluginCommand ¶
func (idx *Index) MapPluginCommand( c *Command, typ string, obj interface{}, f PluginHandler, ) *Command
MapPluginCommand creates a plugin command node.
The function sets up and handle initialization of some plugin components so that the plugin command can work as is expected.
The provided command must have its Run and RunE function vacant when caling the function, otherwise the function raises a panic.
The obj specified will be marshaled into json and supplied to plugin.Command field. If it cannot be marshaled this function will also raises a panic.
The result is just the same as input command, but we will still return that for the package document to aggregate.
func (*Index) MapRuntimeCommand ¶
func (idx *Index) MapRuntimeCommand( c *Command, f RuntimeHandler, ) *Command
MapRuntimeCommand attempts to create a runtime command.
The command will attempt to initialize the runtime object from specified mode with flags, and then invoke the function specified by caller.
type Mode ¶
type Mode interface { Name() string AddFlags(*pflag.FlagSet) Invoke(*Command, []string, ModeHandler) error }
Mode is a delegated object that initializes root object(s), manage their lifecycle(s) and pass it to subcommand.
Mode are arranged on the same level, being selected by "--mode" flag and detail specified through flags. But different modes might possesses completely different root object provision traits.
type ModeHandler ¶
ModeHandler is the handler for the selected mode.
type Partitioner ¶
type Partitioner interface{}
Partitioner is the function that decompose concrete type into root object and arguments.
When the partitioner is for the root type itself, the form of "func(Type) Root" is just ok, and no argument will be generated this case. When the partitioner is for some object beneath the root, then "func(Type) (Root, string)" is required. The Type will be used for registering directly.
type PluginHandler ¶
PluginHandler is the handler for valid plugin command.
type Root ¶
type Root interface { Mode() string Options() plugin.ExecOption }
Root is the search root for each commands.
When executing a plugin command, we will first specify mode and its related flags, which creates a search root for entities waiting to come, then specify the identifiers for entities (e.g. api.Image).
type RuntimeHandler ¶
RuntimeHandler is the handler for specified runtimes.
type UniqueRoot ¶
type UniqueRoot interface { Root ID() interface{} }
UniqueRoot is a root which can be uniquely identified.
The identifier should be a hashable object and we will use sync.Map.Store to store that object as key.