Documentation ¶
Index ¶
- Constants
- Variables
- func SendLog(a IAction, step, format string, i ...interface{}) error
- func Serve(a CDSAction)
- func SetTrace(traceHandle io.Writer)
- type Action
- type Arguments
- type CDSAction
- type CDSActionPlugin
- type CDSActionRPC
- type CDSActionRPCServer
- func (c *CDSActionRPCServer) Author(args interface{}, resp *string) error
- func (c *CDSActionRPCServer) Description(args interface{}, resp *string) error
- func (c *CDSActionRPCServer) Init(args interface{}, resp *string) error
- func (c *CDSActionRPCServer) Name(args interface{}, resp *string) error
- func (c *CDSActionRPCServer) Parameters(args interface{}, resp *Parameters) error
- func (c *CDSActionRPCServer) Run(args interface{}, resp *Result) error
- type Client
- type Common
- type IAction
- type IArguments
- type IOptions
- type IParameters
- type Log
- type Options
- type ParameterType
- type Parameters
- type Result
Constants ¶
const ( MaxTries = 5 RequestTimeout = time.Minute AuthHeader = "X_AUTH_HEADER" RequestedWithValue = "X-CDS-SDK" RequestedWithHeader = "X-Requested-With" )
HTTP Constants
Variables ¶
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "CDS_PLUGIN_MAGIC_COOKIE",
MagicCookieValue: "Q0RTX1BMVUdJTl9NQUdJQ19DT09LSUU=",
}
Handshake is the HandshakeConfig used to configure clients and servers.
var ( //Trace is a debug logger Trace *log.Logger )
Functions ¶
Types ¶
type CDSAction ¶
type CDSAction interface { Init(IOptions) string Name() string Description() string Author() string Parameters() Parameters Run(IAction) Result }
CDSAction is the standard CDSAction Plugin interface
type CDSActionPlugin ¶
type CDSActionPlugin struct {
CDSAction
}
CDSActionPlugin is the implementation of plugin.Plugin so we can serve/consume this
func (CDSActionPlugin) Client ¶
func (a CDSActionPlugin) 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 (CDSActionPlugin) PluginName ¶
func (a CDSActionPlugin) PluginName() string
PluginName is name for the plugin
func (CDSActionPlugin) Server ¶
func (a CDSActionPlugin) Server(*plugin.MuxBroker) (interface{}, error)
Server must return an RPC server for this plugin type. We construct a CDSActionRPCServer for this.
type CDSActionRPC ¶
type CDSActionRPC struct {
// contains filtered or unexported fields
}
CDSActionRPC is the struct used by the worker
func (*CDSActionRPC) Author ¶
func (c *CDSActionRPC) Author() string
Author makes rpc call to Author()
func (*CDSActionRPC) Description ¶
func (c *CDSActionRPC) Description() string
Description makes rpc call to Description()
func (*CDSActionRPC) Parameters ¶
func (c *CDSActionRPC) Parameters() Parameters
Parameters makes rpc call to Parameters()
func (*CDSActionRPC) Run ¶
func (c *CDSActionRPC) Run(a IAction) Result
Run makes rpc call to Run() on client side
type CDSActionRPCServer ¶
type CDSActionRPCServer struct {
Impl CDSAction
}
CDSActionRPCServer is the struct called to serve the plugin
func (*CDSActionRPCServer) Author ¶
func (c *CDSActionRPCServer) Author(args interface{}, resp *string) error
Author serves rpc call to Author()
func (*CDSActionRPCServer) Description ¶
func (c *CDSActionRPCServer) Description(args interface{}, resp *string) error
Description serves rpc call to Description()
func (*CDSActionRPCServer) Init ¶
func (c *CDSActionRPCServer) Init(args interface{}, resp *string) error
Init the rpc plugin
func (*CDSActionRPCServer) Name ¶
func (c *CDSActionRPCServer) Name(args interface{}, resp *string) error
Name serves rpc call to Name()
func (*CDSActionRPCServer) Parameters ¶
func (c *CDSActionRPCServer) Parameters(args interface{}, resp *Parameters) error
Parameters serves rpc call to Parameters()
func (*CDSActionRPCServer) Run ¶
func (c *CDSActionRPCServer) Run(args interface{}, resp *Result) error
Run serves rpc call to Run()
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
type Common ¶
type Common struct{}
Common is the base plugin struct every plugin should be composed by
type IParameters ¶
type Log ¶
type Log struct { ActionID int64 `json:"action_build_id"` Step string `json:"step"` Value string `json:"value"` }
Log a a struct to send log to CDS API
type ParameterType ¶
type ParameterType string
const ( Success = "Success" Fail = "Fail" EnvironmentParameter ParameterType = "env" PipelineParameter ParameterType = "pipeline" ListParameter ParameterType = "list" NumberParameter ParameterType = "number" PasswordParameter ParameterType = "password" StringParameter ParameterType = "string" TextParameter ParameterType = "text" BooleanParameter ParameterType = "boolean" )
Different values for result
type Parameters ¶
type Parameters struct { Data map[string]string DataType map[string]ParameterType DataDescription map[string]string }
func NewParameters ¶
func NewParameters() Parameters
func (*Parameters) Add ¶
func (p *Parameters) Add(name string, _type ParameterType, description string, value string)
func (*Parameters) GetDescription ¶
func (p *Parameters) GetDescription(k string) string
func (*Parameters) GetType ¶
func (p *Parameters) GetType(k string) ParameterType
func (*Parameters) GetValue ¶
func (p *Parameters) GetValue(k string) string
func (*Parameters) Names ¶
func (p *Parameters) Names() []string