Documentation
¶
Index ¶
- Constants
- Variables
- func GetExternalServices(j IJob, serviceType string) (sdk.ExternalService, error)
- func InfoMarkdown(pl CDSAction) string
- func Main(p CDSAction)
- func SendLog(j IJob, format string, i ...interface{}) error
- func SendVulnerabilityReport(j IJob, report sdk.VulnerabilityReport) error
- func Serve(a CDSAction)
- func SetTrace(traceHandle io.Writer)
- 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
- func (c *CDSActionRPCServer) Version(args interface{}, resp *string) error
- type Client
- type Common
- type IArguments
- type IJob
- type IOptions
- type IParameters
- type Job
- type Log
- type Options
- type ParameterType
- type Parameters
- type Result
- type Secrets
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 )
var VERSION = "snapshot"
VERSION is set with -ldflags "-X main.VERSION={{.cds.proj.version}}+{{.cds.version}}"
Functions ¶
func GetExternalServices ¶
func GetExternalServices(j IJob, serviceType string) (sdk.ExternalService, error)
GetExternalServices call worker to get external service configuration
func InfoMarkdown ¶
InfoMarkdown returns string formatted with markdown
func SendVulnerabilityReport ¶
func SendVulnerabilityReport(j IJob, report sdk.VulnerabilityReport) error
SendVulnerabilityReport call worker to send vulnerabiliry report to API
Types ¶
type Arguments ¶
Arguments type, key: var name, value: value of argument
type CDSAction ¶
type CDSAction interface {
Init(IOptions) string
Version() string
Name() string
Description() string
Author() string
Parameters() Parameters
Run(IJob) 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 ¶
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
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 IJob) 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()
func (*CDSActionRPCServer) Version ¶
func (c *CDSActionRPCServer) Version(args interface{}, resp *string) error
Version of the rpc plugin
type Client ¶
Client must be used from client side to call the plugin. It's managing plugin instanciation and initializing
type Common ¶
type Common struct {
Name string
Description string
Parameters Parameters
Author string
Format string `json:"-" yaml:"-" xml:"-"`
}
Common is the base plugin struct every plugin should be composed by
type IJob ¶
type IJob interface {
ID() int64
WorkflowNodeRunID() int64
PipelineBuildID() int64
StepOrder() int
WorkerHTTPPort() int
Arguments() Arguments
Secrets() Secrets
}
IJob is the Run() input args of every plugin
type IParameters ¶
type Job ¶
type Job struct {
IDPipelineJobBuild int64
IDWorkflowNodeRun int64
IDPipelineBuild int64
Args Arguments
Secrts Secrets
OrderStep int
HTTPPortWorker int
}
Job is the input of the plugin run function
func (Job) PipelineBuildID ¶
func (Job) WorkerHTTPPort ¶
func (Job) WorkflowNodeRunID ¶
type Log ¶
type Log struct {
BuildID int64 `json:"builID"`
PipelineBuildJobID int64 `json:"pipelineBuildJobID"`
PipelineBuildID int64 `json:"pipelineBuildID"`
Start *timestamp.Timestamp `json:"start"`
LastModified *timestamp.Timestamp `json:"lastModified"`
Done *timestamp.Timestamp `json:"done"`
StepOrder int `json:"stepOrder"`
Value string `json:"val"`
}
Log struct holds a single line of build log
type ParameterType ¶
type ParameterType string
const ( Success = "Success" Fail = "Fail" EnvironmentParameter ParameterType = "env" PipelineParameter ParameterType = "pipeline" ListParameter ParameterType = "list" NumberParameter ParameterType = "number" 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