template

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxTries            = 5
	RequestTimeout      = time.Minute
	AuthHeader          = "X_AUTH_HEADER"
	RequestedWithValue  = "X-CDS-SDK"
	RequestedWithHeader = "X-Requested-With"
)

HTTP Constants

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "CDS_TEMPLATE_MAGIC_COOKIE",
	MagicCookieValue: "Q0RTX1RFTVBMQVRFX01BR0lDX0NPT0tJRQ==",
}

Handshake is the HandshakeConfig used to configure clients and servers.

View Source
var (

	//Trace is a debug logger
	Trace *log.Logger
)

Functions

func Serve

func Serve(a Interface)

Serve has to be called in main func of every plugin

func SetTrace

func SetTrace(traceHandle io.Writer)

SetTrace is for debug

Types

type ApplyOptions

type ApplyOptions struct {
	ProjKey string
	AppName string
	Params  MapVar
}

ApplyOptions represents struct for Apply func arg

func NewApplyOptions

func NewApplyOptions(proj, app string, params Parameters) ApplyOptions

NewApplyOptions instanciate a ApplyOptions struct

func (ApplyOptions) ApplicationName

func (o ApplyOptions) ApplicationName() string

ApplicationName returns the application name

func (ApplyOptions) Parameters

func (o ApplyOptions) Parameters() MapVar

Parameters returns the list of parameters

func (ApplyOptions) ProjetKey

func (o ApplyOptions) ProjetKey() string

ProjetKey returns the project key

type CDSTemplateExtension

type CDSTemplateExtension struct {
	Interface
}

CDSTemplateExtension is the implementation of plugin.Plugin so we can serve/consume this

func (CDSTemplateExtension) Client

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

Client must return an implementation of our interface that communicates over an RPC client. We return CDSActionRPC for this.

func (CDSTemplateExtension) PluginName

func (a CDSTemplateExtension) PluginName() string

PluginName is name for the plugin

func (CDSTemplateExtension) Server

func (a CDSTemplateExtension) Server(*plugin.MuxBroker) (interface{}, error)

Server must return an RPC server for this plugin type. We construct a RPCServer for this.

type Client

type Client struct {
	*plugin.Client
	// contains filtered or unexported fields
}

Client must be used from client side to call the plugin. It's managing plugin instanciation and initializing

func NewClient

func NewClient(name, binary, id, url string, tlsSkipVerify bool) *Client

NewClient has to be called every time we nedd to call a plugin

func (Client) Instance

func (p Client) Instance() (Interface, error)

Instance return a fresh instance of the CDSAction plugin dispensed by a RPC server

type Common

type Common struct{}

Common is the base plugin struct every plugin should be composed by

func (*Common) Init

func (p *Common) Init(o plugin.IOptions) string

Init is a common function for all plugins

type IApplyOptions

type IApplyOptions interface {
	ProjetKey() string
	ApplicationName() string
	Parameters() MapVar
}

IApplyOptions represents interface for Apply func arg

type Interface

type Interface interface {
	Init(plugin.IOptions) string
	Name() string
	Description() string
	Identifier() string
	Author() string
	Type() string
	Parameters() []sdk.TemplateParam
	ActionsNeeded() []string
	Apply(opts IApplyOptions) (sdk.Application, error)
}

Interface is the interface for template extensions

type MapVar

type MapVar interface {
	All() map[string]string
	Get(string) string
}

MapVar is an interface for map[string]string

type Parameters

type Parameters struct {
	Data map[string]string
}

Parameters represents the parameters map expected bu the template

func NewParameters

func NewParameters(d map[string]string) *Parameters

NewParameters instanciates a parameters struct

func (Parameters) All

func (d Parameters) All() map[string]string

All returns the map

func (Parameters) Get

func (d Parameters) Get(k string) string

Get returns the value in the map for the key k

type RPCClient

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

RPCClient is the client for the template extension

func (*RPCClient) ActionsNeeded

func (c *RPCClient) ActionsNeeded() []string

func (*RPCClient) Apply

func (c *RPCClient) Apply(opts IApplyOptions) (sdk.Application, error)

Apply create a fresh new CDS application from the template extension

func (*RPCClient) Author

func (c *RPCClient) Author() string

Author returns the author's name the the template extension

func (*RPCClient) Description

func (c *RPCClient) Description() string

Description returns the description of the template extension

func (*RPCClient) Identifier

func (c *RPCClient) Identifier() string

Identifier returns the identifier of the template extension

func (*RPCClient) Init

func (c *RPCClient) Init(opts plugin.IOptions) string

Init initializes the template extension

func (*RPCClient) Name

func (c *RPCClient) Name() string

Name returns the name of the template extension

func (*RPCClient) Parameters

func (c *RPCClient) Parameters() []sdk.TemplateParam

Parameters returns the list of template parameters

func (*RPCClient) Type

func (c *RPCClient) Type() string

Type returns the type of the template type

type RPCServer

type RPCServer struct {
	Impl Interface
}

RPCServer is the struct called to serve the plugin

func (*RPCServer) ActionsNeeded

func (s *RPCServer) ActionsNeeded(args interface{}, resp *[]string) error

ActionsNeeded returns the list of needed action of the template

func (*RPCServer) Apply

func (s *RPCServer) Apply(args interface{}, resp *sdk.Application) error

Apply returns an application instance ready to persist in database

func (*RPCServer) Author

func (s *RPCServer) Author(args interface{}, resp *string) error

Author returns the author's name of the template

func (*RPCServer) Description

func (s *RPCServer) Description(args interface{}, resp *string) error

Description returns the description of the template

func (*RPCServer) Identifier

func (s *RPCServer) Identifier(args interface{}, resp *string) error

Identifier returns the identifier of the template

func (*RPCServer) Init

func (s *RPCServer) Init(args interface{}, resp *string) error

Init the rpc plugin

func (*RPCServer) Name

func (s *RPCServer) Name(args interface{}, resp *string) error

Name returns name of the template

func (*RPCServer) Parameters

func (s *RPCServer) Parameters(args interface{}, resp *[]sdk.TemplateParam) error

Parameters returns parameters of the template

func (*RPCServer) Type

func (s *RPCServer) Type(args interface{}, resp *string) error

Type returns type of the template

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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