fungo

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 8

Documentation

Index

Constants

View Source
const PluginTypeEnvName = "HRP_PLUGIN_TYPE"

PluginTypeEnvName is used to specify hashicorp go plugin type, rpc/grpc

View Source
const Version = "v0.5.4"

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "HttpRunnerPlus",
	MagicCookieValue: "debugtalk",
}

HandshakeConfig is used to just do a basic handshake between a plugin and host. If the handshake fails, a user friendly error is shown. This prevents users from executing bad plugins or executing a plugin directory. It is a UX feature, not a security feature.

View Source
var Logger = hclog.New(&hclog.LoggerOptions{
	Name:        "fungo",
	Output:      hclog.DefaultOutput,
	DisableTime: true,
	Level:       hclog.Debug,
	Color:       hclog.AutoColor,
})

Functions

func CallFunc added in v0.5.2

func CallFunc(fn reflect.Value, args ...interface{}) (interface{}, error)

CallFunc calls function with arguments

func CloseLogFile added in v0.5.2

func CloseLogFile() error

func ConvertCommonName added in v0.5.2

func ConvertCommonName(name string) string

ConvertCommonName returns name which deleted "_" and converted capital letter to their lower case

func InitLogger added in v0.5.2

func InitLogger(logLevel hclog.Level, logFile string, disableTime bool) hclog.Logger

func Register

func Register(funcName string, fn interface{})

Register registers a plugin function. Every plugin function must be registered before Serve() is called.

func Serve

func Serve()

default to run plugin in gRPC mode

Types

type GRPCPlugin

type GRPCPlugin struct {
	plugin.Plugin
	Impl IFuncCaller
}

GRPCPlugin implements hashicorp's plugin.GRPCPlugin.

func (*GRPCPlugin) GRPCClient

func (p *GRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*GRPCPlugin) GRPCServer

func (p *GRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type IFuncCaller added in v0.5.2

type IFuncCaller interface {
	GetNames() ([]string, error)                                    // get all plugin function names list
	Call(funcName string, args ...interface{}) (interface{}, error) // call plugin function
}

IFuncCaller is the interface that we're exposing as a plugin.

type RPCPlugin

type RPCPlugin struct {
	Impl IFuncCaller
}

RPCPlugin implements hashicorp's plugin.Plugin.

func (*RPCPlugin) Client

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

func (*RPCPlugin) Server

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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