plugins

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2020 License: MIT Imports: 3 Imported by: 0

README

Transforms

Customer data is available in lots of different formats. The tool provides a plugin loading mechanism for transforming that data into the dsl format used by the tool.

This provides an extension mechanism for writing customer plugins for doing the conversion.

The plugin technology is based on hashicorp go-plugin a RPC based solution for Go plugins.
An interface is defined that plugin authors must implement:

// Arguments - composite for passing data across net/rpc
type Arguments struct {
	InputDirectory string
	CmdLineArgs    []string
}

// Transformer is the interface that must be implemented by plugin authors.
type Transformer interface {
	Devices(args Arguments) (dsl.Devices, error)
}

CSV Transform

The sample plugin provides a transform for mapping CSV files into the Device dsl required by Healthbot.

The plugin expects to parse CSV files in the following format:

device-id,host,username,password
mx1,10.0.0.1,root,changeme
mx2,10.0.0.2,root,"changeme now"
mx3,10.0.0.3,,

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arguments

type Arguments struct {
	InputDirectory string
	CmdLineArgs    []string
}

Arguments - composite for passing data across net/rpc

type Transformer

type Transformer interface {
	Devices(args Arguments) (dsl.Devices, error)
}

Transformer is the interface that must be implemented by plugin authors.

type TransformerPlugin

type TransformerPlugin struct {
	// Impl Injection
	Impl Transformer
}

TransformerPlugin is the implementation of plugin.Devices so we can serve/consume this

func (TransformerPlugin) Client

func (TransformerPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client - muxing

func (*TransformerPlugin) Server

func (p *TransformerPlugin) Server(*plugin.MuxBroker) (interface{}, error)

Server - muxing

type TransformerRPC

type TransformerRPC struct {
	// contains filtered or unexported fields
}

TransformerRPC - an implementation that talks over RPC

func (*TransformerRPC) Devices

func (g *TransformerRPC) Devices(args Arguments) (resp dsl.Devices, err error)

Devices - interface implementation

type TransformerRPCServer

type TransformerRPCServer struct {
	Impl Transformer
}

TransformerRPCServer - is the RPC server that TransformerRPC talks to, conforming to the requirements of net/rpc

func (*TransformerRPCServer) Devices

func (s *TransformerRPCServer) Devices(args Arguments, resp *dsl.Devices) (err error)

Devices - Server implementation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL