Documentation
¶
Index ¶
- Constants
- Variables
- func AnyToString(value any) (string, bool)
- func AssignStruct(pa ActionsParams, st any) error
- func DiffJSON(src, target map[string]any) string
- func DisableSecurityExit(disabled bool)
- func EnvMap() map[string]string
- func FlattenInterface(i any) map[string]string
- func MapToStructByTags(params map[string]any, dest any) error
- func MatchJSON(src, target map[string]any) bool
- func MergeMaps(base, over map[string]any) map[string]any
- func MergeStringMaps(base map[string]string, over map[string]any) map[string]string
- func RunActions(name string, args []string, with map[string]any, verbose bool) (map[string]any, error)
- func StrmapToAnymap(strmap map[string]string) map[string]any
- func StructToMapByTags(src any) (map[string]any, error)
- func TitleCase(st string, char string) string
- func UnflattenInterface(flatMap map[string]string) map[string]any
- type Actions
- type ActionsArgs
- type ActionsClient
- type ActionsParams
- type ActionsPlugin
- type ActionsServer
- type BufferedJobExecutor
- type Config
- type ExecutionConfig
- type ExecutionResult
- type Expr
- func (e *Expr) Eval(input string, env any) (any, error)
- func (e *Expr) EvalOrEvalTemplate(input string, env any) (string, error)
- func (e *Expr) EvalTemplate(input string, env any) (string, error)
- func (e *Expr) EvalTemplateMap(input map[string]any, env any) map[string]any
- func (e *Expr) Options(env any) []ex.Option
- type Interval
- type Job
- type JobContext
- type JobExecutor
- type JobOutput
- type JobScheduler
- func (js *JobScheduler) AddJob(job *Job) error
- func (js *JobScheduler) AllJobsCompleted() bool
- func (js *JobScheduler) CanRunJob(jobID string) bool
- func (js *JobScheduler) GetRepeatInfo(jobID string) (current, target int)
- func (js *JobScheduler) GetRunnableJobs() []string
- func (js *JobScheduler) IncrementRepeatCounter(jobID string)
- func (js *JobScheduler) MarkJobsWithFailedDependencies() []string
- func (js *JobScheduler) SetJobStatus(jobID string, status JobStatus, success bool)
- func (js *JobScheduler) ShouldRepeatJob(jobID string) bool
- func (js *JobScheduler) ValidateDependencies() error
- type JobStatus
- type Output
- func (o *Output) PrintError(format string, args ...interface{})
- func (o *Output) PrintJobName(name string)
- func (o *Output) PrintJobOutput(output string)
- func (o *Output) PrintJobResult(jobName string, status StatusType, duration float64)
- func (o *Output) PrintSeparator()
- func (o *Output) PrintStepRepeatResult(stepIdx int, counter StepRepeatCounter, hasTest bool)
- func (o *Output) PrintStepRepeatStart(stepIdx int, stepName string, repeatCount int)
- func (o *Output) PrintStepResult(step StepResult)
- func (o *Output) PrintVerbose(format string, args ...interface{})
- func (o *Output) PrintWorkflowHeader(name, description string)
- func (o *Output) PrintWorkflowSummary(totalTime float64, successCount, totalJobs int)
- type OutputWriter
- type ParallelJobExecutor
- type Probe
- type Repeat
- type SequentialJobExecutor
- type StatusType
- type Step
- func (st *Step) Do(jCtx *JobContext)
- func (st *Step) DoEcho()
- func (st *Step) DoEchoWithSequentialPrint()
- func (st *Step) DoTest() (string, bool)
- func (st *Step) DoTestWithSequentialPrint() bool
- func (st *Step) SetCtx(j JobContext, override map[string]any)
- func (st *Step) ShowRequestResponse(name string)
- type StepContext
- type StepRepeatCounter
- type StepResult
- type ValidationError
- type Workflow
- type WorkflowOutput
Constants ¶
const ( IconSuccess = "✔︎ " IconError = "✘ " IconWarning = "▲ " IconCircle = "⏺ " )
Icon constants
Variables ¶
var ( BuiltinCmd = "builtin-actions" Handshake = plugin.HandshakeConfig{ProtocolVersion: 1, MagicCookieKey: "probe", MagicCookieValue: "actions"} PluginMap = map[string]plugin.Plugin{"actions": &ActionsPlugin{}} )
Functions ¶
func AnyToString ¶ added in v0.4.0
AnyToString attempts to convert any type to a string.
func AssignStruct ¶
func AssignStruct(pa ActionsParams, st any) error
func DiffJSON ¶ added in v0.4.0
DiffJSON compares two `map[string]any` objects strictly and collects differences.
func DisableSecurityExit ¶ added in v0.5.0
func DisableSecurityExit(disabled bool)
DisableSecurityExit disables process termination on security violations When enabled, security violations return errors instead of calling os.Exit(2)
func FlattenInterface ¶
func MapToStructByTags ¶
converting from a map[string]any to a struct
func MatchJSON ¶ added in v0.4.0
MatchJSON compares two `map[string]any` objects strictly. All fields in `src` and `target` must match, including structure and values.
func MergeMaps ¶ added in v0.4.0
MergeMaps merges two maps of type map[string]any. If keys conflict, the values from over override those in base. Nested maps are merged recursively.
func MergeStringMaps ¶
merge string maps
func RunActions ¶
func StructToMapByTags ¶
converting from a struct to a map[string]any
Types ¶
type ActionsArgs ¶
type ActionsArgs []string
type ActionsClient ¶
type ActionsClient struct {
// contains filtered or unexported fields
}
type ActionsParams ¶
type ActionsPlugin ¶
func (*ActionsPlugin) GRPCClient ¶
func (p *ActionsPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)
func (*ActionsPlugin) GRPCServer ¶
func (p *ActionsPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type ActionsServer ¶
type ActionsServer struct {
Impl Actions
}
func (*ActionsServer) Run ¶
func (m *ActionsServer) Run(ctx context.Context, req *pb.RunRequest) (*pb.RunResponse, error)
type BufferedJobExecutor ¶ added in v0.6.0
type BufferedJobExecutor struct {
// contains filtered or unexported fields
}
BufferedJobExecutor handles job execution with buffered output
func NewBufferedJobExecutor ¶ added in v0.6.0
func NewBufferedJobExecutor(w *Workflow) *BufferedJobExecutor
NewBufferedJobExecutor creates a new buffered job executor
func (*BufferedJobExecutor) Execute ¶ added in v0.6.0
func (e *BufferedJobExecutor) Execute(job *Job, jobID string, ctx JobContext, config ExecutionConfig) ExecutionResult
Execute runs a job with buffered output
type ExecutionConfig ¶ added in v0.6.0
type ExecutionConfig struct {
UseBuffering bool
UseParallel bool
HasDependencies bool
WorkflowOutput *WorkflowOutput
JobScheduler *JobScheduler
}
ExecutionConfig contains configuration for job execution
type ExecutionResult ¶ added in v0.6.0
ExecutionResult represents the result of a job execution
type Expr ¶ added in v0.2.0
type Expr struct{}
func (*Expr) EvalOrEvalTemplate ¶ added in v0.4.0
func (*Expr) EvalTemplate ¶ added in v0.2.0
func (*Expr) EvalTemplateMap ¶ added in v0.4.0
type Interval ¶ added in v0.6.0
Interval represents a time interval that can be specified as a number (seconds) or duration string
func (Interval) MarshalYAML ¶ added in v0.6.0
MarshalYAML implements custom YAML marshaling for Interval
func (*Interval) UnmarshalYAML ¶ added in v0.6.0
UnmarshalYAML implements custom YAML unmarshaling for Interval
type Job ¶
type Job struct {
Name string `yaml:"name",validate:"required"`
ID string `yaml:"id,omitempty"`
Needs []string `yaml:"needs,omitempty"`
Steps []*Step `yaml:"steps",validate:"required"`
Repeat *Repeat `yaml:"repeat"`
Defaults any `yaml:"defaults"`
// contains filtered or unexported fields
}
func (*Job) Start ¶
func (j *Job) Start(ctx JobContext) bool
type JobContext ¶
type JobContext struct {
Vars map[string]any `expr:"vars"`
Logs []map[string]any `expr:"steps"`
Config
Failed bool
// Repeat tracking
IsRepeating bool
RepeatCurrent int
RepeatTotal int
StepCounters map[int]StepRepeatCounter // step index -> counter
// Output buffering
UseBuffering bool
// Output writer
Output OutputWriter
}
func (*JobContext) SetFailed ¶ added in v0.2.0
func (j *JobContext) SetFailed()
type JobExecutor ¶ added in v0.6.0
type JobExecutor interface {
Execute(job *Job, jobID string, ctx JobContext, config ExecutionConfig) ExecutionResult
}
JobExecutor defines the interface for executing jobs
type JobOutput ¶ added in v0.6.0
type JobOutput struct {
JobName string
JobID string
Buffer strings.Builder
Status string
StartTime time.Time
EndTime time.Time
Success bool
// contains filtered or unexported fields
}
JobOutput stores buffered output for a job
type JobScheduler ¶ added in v0.5.0
type JobScheduler struct {
// contains filtered or unexported fields
}
func NewJobScheduler ¶ added in v0.5.0
func NewJobScheduler() *JobScheduler
func (*JobScheduler) AddJob ¶ added in v0.5.0
func (js *JobScheduler) AddJob(job *Job) error
func (*JobScheduler) AllJobsCompleted ¶ added in v0.5.0
func (js *JobScheduler) AllJobsCompleted() bool
func (*JobScheduler) CanRunJob ¶ added in v0.5.0
func (js *JobScheduler) CanRunJob(jobID string) bool
func (*JobScheduler) GetRepeatInfo ¶ added in v0.5.0
func (js *JobScheduler) GetRepeatInfo(jobID string) (current, target int)
GetRepeatInfo returns current repeat counter and target for a job
func (*JobScheduler) GetRunnableJobs ¶ added in v0.5.0
func (js *JobScheduler) GetRunnableJobs() []string
func (*JobScheduler) IncrementRepeatCounter ¶ added in v0.5.0
func (js *JobScheduler) IncrementRepeatCounter(jobID string)
IncrementRepeatCounter increments the repeat counter for a job
func (*JobScheduler) MarkJobsWithFailedDependencies ¶ added in v0.6.0
func (js *JobScheduler) MarkJobsWithFailedDependencies() []string
MarkJobsWithFailedDependencies marks jobs as failed if their dependencies have failed
func (*JobScheduler) SetJobStatus ¶ added in v0.5.0
func (js *JobScheduler) SetJobStatus(jobID string, status JobStatus, success bool)
func (*JobScheduler) ShouldRepeatJob ¶ added in v0.5.0
func (js *JobScheduler) ShouldRepeatJob(jobID string) bool
ShouldRepeatJob checks if a job should be repeated
func (*JobScheduler) ValidateDependencies ¶ added in v0.5.0
func (js *JobScheduler) ValidateDependencies() error
type Output ¶ added in v0.6.0
type Output struct {
// contains filtered or unexported fields
}
Output implements OutputWriter for console output
func (*Output) PrintError ¶ added in v0.6.0
PrintError prints an error message
func (*Output) PrintJobName ¶ added in v0.6.0
PrintJobName prints the job name
func (*Output) PrintJobOutput ¶ added in v0.6.0
PrintJobOutput prints buffered job output
func (*Output) PrintJobResult ¶ added in v0.6.0
func (o *Output) PrintJobResult(jobName string, status StatusType, duration float64)
PrintJobResult prints the result of a job execution
func (*Output) PrintSeparator ¶ added in v0.6.0
func (o *Output) PrintSeparator()
PrintSeparator prints a separator line for verbose output
func (*Output) PrintStepRepeatResult ¶ added in v0.6.0
func (o *Output) PrintStepRepeatResult(stepIdx int, counter StepRepeatCounter, hasTest bool)
PrintStepRepeatResult prints the final result of a repeated step execution
func (*Output) PrintStepRepeatStart ¶ added in v0.6.0
PrintStepRepeatStart prints the start of a repeated step execution
func (*Output) PrintStepResult ¶ added in v0.6.0
func (o *Output) PrintStepResult(step StepResult)
PrintStepResult prints the result of a single step execution
func (*Output) PrintVerbose ¶ added in v0.6.0
PrintVerbose prints verbose output (only if verbose mode is enabled)
func (*Output) PrintWorkflowHeader ¶ added in v0.6.0
PrintWorkflowHeader prints the workflow name and description
func (*Output) PrintWorkflowSummary ¶ added in v0.6.0
PrintWorkflowSummary prints the workflow execution summary
type OutputWriter ¶ added in v0.6.0
type OutputWriter interface {
// Workflow level output
PrintWorkflowHeader(name, description string)
PrintJobName(name string)
// Step level output
PrintStepResult(step StepResult)
PrintStepRepeatStart(stepIdx int, stepName string, repeatCount int)
PrintStepRepeatResult(stepIdx int, counter StepRepeatCounter, hasTest bool)
// Job level output
PrintJobResult(jobName string, status StatusType, duration float64)
PrintJobOutput(output string)
// Workflow summary
PrintWorkflowSummary(totalTime float64, successCount, totalJobs int)
// Error output
PrintError(format string, args ...interface{})
// Verbose output
PrintVerbose(format string, args ...interface{})
PrintSeparator()
}
OutputWriter defines the interface for different output implementations
type ParallelJobExecutor ¶ added in v0.6.0
type ParallelJobExecutor struct {
// contains filtered or unexported fields
}
ParallelJobExecutor handles parallel job execution without dependencies
func NewParallelJobExecutor ¶ added in v0.6.0
func NewParallelJobExecutor(w *Workflow) *ParallelJobExecutor
NewParallelJobExecutor creates a new parallel job executor
func (*ParallelJobExecutor) Execute ¶ added in v0.6.0
func (e *ParallelJobExecutor) Execute(job *Job, jobID string, ctx JobContext, config ExecutionConfig) ExecutionResult
Execute runs a job in parallel mode
type Probe ¶
func (*Probe) ExitStatus ¶ added in v0.2.0
type Repeat ¶
type Repeat struct {
Count int `yaml:"count",validate:"required,gte=0,lt=100"`
Interval Interval `yaml:"interval"`
}
Repeat defines the repeat configuration for jobs
type SequentialJobExecutor ¶ added in v0.6.0
type SequentialJobExecutor struct {
// contains filtered or unexported fields
}
SequentialJobExecutor handles sequential job execution with dependencies
func NewSequentialJobExecutor ¶ added in v0.6.0
func NewSequentialJobExecutor(w *Workflow) *SequentialJobExecutor
NewSequentialJobExecutor creates a new sequential job executor
func (*SequentialJobExecutor) Execute ¶ added in v0.6.0
func (e *SequentialJobExecutor) Execute(job *Job, jobID string, ctx JobContext, config ExecutionConfig) ExecutionResult
Execute runs a job in sequential mode with dependency management
type StatusType ¶ added in v0.6.0
type StatusType int
StatusType represents the status of execution
const ( StatusSuccess StatusType = iota StatusError StatusWarning )
type Step ¶
type Step struct {
Name string `yaml:"name"`
Uses string `yaml:"uses" validate:"required"`
With map[string]any `yaml:"with"`
Test string `yaml:"test"`
Echo string `yaml:"echo"`
Vars map[string]any `yaml:"vars"`
Iter []map[string]any `yaml:"iter"`
// contains filtered or unexported fields
}
func (*Step) Do ¶ added in v0.5.0
func (st *Step) Do(jCtx *JobContext)
func (*Step) DoEchoWithSequentialPrint ¶ added in v0.5.0
func (st *Step) DoEchoWithSequentialPrint()
func (*Step) DoTestWithSequentialPrint ¶ added in v0.5.0
func (*Step) ShowRequestResponse ¶ added in v0.5.0
type StepContext ¶ added in v0.5.0
type StepRepeatCounter ¶ added in v0.6.0
type StepRepeatCounter struct {
SuccessCount int
FailureCount int
Name string
LastResult bool
Output strings.Builder
}
StepRepeatCounter tracks the execution results of repeated steps
type StepResult ¶ added in v0.6.0
type StepResult struct {
Index int
Name string
Status StatusType
RT string
TestOutput string
EchoOutput string
HasTest bool
}
StepResult represents the result of a step execution
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
func (*ValidationError) AddMessage ¶
func (e *ValidationError) AddMessage(s string)
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) HasError ¶
func (e *ValidationError) HasError() bool
type Workflow ¶
type Workflow struct {
Name string `yaml:"name",validate:"required"`
Description string `yaml:"description,omitempty"`
Jobs []Job `yaml:"jobs",validate:"required"`
Vars map[string]any `yaml:"vars"`
// contains filtered or unexported fields
}
func (*Workflow) SetExitStatus ¶ added in v0.2.0
type WorkflowOutput ¶ added in v0.6.0
WorkflowOutput manages output for multiple jobs
func NewWorkflowOutput ¶ added in v0.6.0
func NewWorkflowOutput() *WorkflowOutput
NewWorkflowOutput creates a new WorkflowOutput instance