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 EnvMap() map[string]string
- func FlattenInterface(i any) map[string]string
- func GetTruncationMessage() 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 TruncateMapStringString(params map[string]string, maxLen int) map[string]string
- func TruncateString(s string, maxLen int) string
- func UnflattenInterface(flatMap map[string]string) map[string]any
- type Actions
- type ActionsArgs
- type ActionsClient
- type ActionsParams
- type ActionsPlugin
- type ActionsServer
- type Config
- type ErrorType
- type Executor
- 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 JobResult
- 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 LogLevel
- type Outputs
- type Printer
- func (p *Printer) AddSpinnerSuffix(txt string)
- func (p *Printer) LogDebug(format string, args ...interface{})
- func (p *Printer) LogError(format string, args ...interface{})
- func (p *Printer) PrintEchoContent(content string)
- func (p *Printer) PrintError(format string, args ...interface{})
- func (p *Printer) PrintHeader(name, description string)
- func (p *Printer) PrintMapData(data map[string]any)
- func (p *Printer) PrintReport(rs *Result)
- func (p *Printer) PrintRequestResponse(stepIdx int, stepName string, req, res map[string]any, rt string)
- func (p *Printer) PrintSeparator()
- func (p *Printer) PrintTestResult(success bool, testExpr string, context interface{})
- func (p *Printer) PrintVerbose(format string, args ...interface{})
- func (p *Printer) StartSpinner()
- func (p *Printer) StopSpinner()
- type Probe
- type ProbeError
- func NewActionError(operation, message string, cause error) *ProbeError
- func NewConfigurationError(operation, message string, cause error) *ProbeError
- func NewExecutionError(operation, message string, cause error) *ProbeError
- func NewFileError(operation, message string, cause error) *ProbeError
- func NewProbeError(errorType ErrorType, operation, message string, cause error) *ProbeError
- type Repeat
- type Result
- type StatusType
- type Step
- func (st *Step) Do(jCtx *JobContext)
- func (st *Step) DoEcho(jCtx *JobContext)
- func (st *Step) DoEchoWithSequentialPrint(jCtx *JobContext)
- func (st *Step) DoTest(printer *Printer) (string, bool)
- func (st *Step) DoTestWithSequentialPrint(jCtx *JobContext) bool
- func (st *Step) SetCtx(j JobContext, override map[string]any)
- func (st *Step) ShowRequestResponse(name string, jCtx *JobContext)
- type StepContext
- type StepRepeatCounter
- type StepResult
- type ValidationError
- type Workflow
Constants ¶
const ( // MaxLogStringLength is the maximum length for log output to prevent log bloat MaxLogStringLength = 200 // MaxStringLength is the maximum length for general string processing MaxStringLength = 1000000 )
const ( IconSuccess = "✔︎ " IconError = "✘ " IconWarning = "▲ " IconCircle = "⏺ " IconWait = "🕐︎" IconSkip = "⏭ " )
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 FlattenInterface ¶
func GetTruncationMessage ¶ added in v0.9.0
func GetTruncationMessage() string
GetTruncationMessage returns a colored truncation message
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
func TruncateMapStringString ¶ added in v0.9.0
TruncateMapStringString truncates long values in map[string]string for logging
func TruncateString ¶ added in v0.9.0
TruncateString truncates a string if it exceeds the maximum length
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 ErrorType ¶ added in v0.7.0
type ErrorType string
ErrorType represents different categories of errors
const ( ErrorTypeValidation ErrorType = "validation" ErrorTypeExecution ErrorType = "execution" ErrorTypeConfiguration ErrorType = "configuration" ErrorTypeNetwork ErrorType = "network" ErrorTypeFile ErrorType = "file" ErrorTypeAction ErrorType = "action" ErrorTypeDependency ErrorType = "dependency" )
type Executor ¶ added in v0.8.0
type Executor struct {
// contains filtered or unexported fields
}
Executor handles job execution with buffered output
func NewExecutor ¶ added in v0.8.0
NewExecutor creates a new job executor
func (*Executor) Execute ¶ added in v0.8.0
func (e *Executor) Execute(ctx JobContext) bool
Execute runs a job with buffered output
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) error
type JobContext ¶
type JobContext struct {
Vars map[string]any `expr:"vars"`
Logs []map[string]any `expr:"steps"`
Config
Failed bool
// Current job ID for this context
CurrentJobID string
// Repeat tracking
IsRepeating bool
RepeatCurrent int
RepeatTotal int
StepCounters map[int]StepRepeatCounter // step index -> counter
// Print writer
Printer *Printer
// Result for managing job-level output
Result *Result
// Job scheduler for managing job dependencies and execution
JobScheduler *JobScheduler
// Shared outputs across all jobs (accessible via expressions as "outputs")
Outputs *Outputs `expr:"outputs"`
}
JobContext provides context data for job execution
func (*JobContext) SetFailed ¶ added in v0.2.0
func (j *JobContext) SetFailed()
SetFailed marks the job context as failed
type JobResult ¶ added in v0.8.0
type JobResult struct {
JobName string
JobID string
Status string
StartTime time.Time
EndTime time.Time
Success bool
StepResults []StepResult // Store all step results for this job
// contains filtered or unexported fields
}
JobResult stores execution results 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 Outputs ¶ added in v0.7.0
type Outputs struct {
// contains filtered or unexported fields
}
Outputs manages step outputs across the entire workflow
func NewOutputs ¶ added in v0.7.0
func NewOutputs() *Outputs
NewOutputs creates a new Outputs instance
type Printer ¶ added in v0.7.0
type Printer struct {
Buffer map[string]*strings.Builder
BufferIDs []string // Order preservation
// contains filtered or unexported fields
}
Printer implements PrintWriter for console print
func NewPrinter ¶ added in v0.7.0
NewPrinter creates a new console print writer
func (*Printer) AddSpinnerSuffix ¶ added in v0.8.0
func (*Printer) PrintEchoContent ¶ added in v0.10.0
PrintEchoContent prints echo content with proper indentation in verbose mode
func (*Printer) PrintError ¶ added in v0.7.0
PrintError prints an error message
func (*Printer) PrintHeader ¶ added in v0.8.0
PrintHeader prints the workflow name and description
func (*Printer) PrintMapData ¶ added in v0.10.0
PrintMapData prints map data with proper formatting for nested structures
func (*Printer) PrintReport ¶ added in v0.8.0
PrintReport prints a complete workflow report using Result data
func (*Printer) PrintRequestResponse ¶ added in v0.10.0
func (p *Printer) PrintRequestResponse(stepIdx int, stepName string, req, res map[string]any, rt string)
PrintRequestResponse prints request and response data with proper formatting
func (*Printer) PrintSeparator ¶ added in v0.7.0
func (p *Printer) PrintSeparator()
PrintSeparator prints a separator line for verbose output
func (*Printer) PrintTestResult ¶ added in v0.10.0
PrintTestResult prints test result in verbose mode
func (*Printer) PrintVerbose ¶ added in v0.7.0
PrintVerbose prints verbose output (only if verbose mode is enabled)
func (*Printer) StartSpinner ¶ added in v0.8.0
func (p *Printer) StartSpinner()
func (*Printer) StopSpinner ¶ added in v0.8.0
func (p *Printer) StopSpinner()
type Probe ¶
func (*Probe) ExitStatus ¶ added in v0.2.0
type ProbeError ¶ added in v0.7.0
type ProbeError struct {
Type ErrorType
Operation string
Message string
Cause error
Context map[string]interface{}
}
ProbeError is the base error type with context information
func NewActionError ¶ added in v0.7.0
func NewActionError(operation, message string, cause error) *ProbeError
func NewConfigurationError ¶ added in v0.7.0
func NewConfigurationError(operation, message string, cause error) *ProbeError
func NewExecutionError ¶ added in v0.7.0
func NewExecutionError(operation, message string, cause error) *ProbeError
func NewFileError ¶ added in v0.7.0
func NewFileError(operation, message string, cause error) *ProbeError
func NewProbeError ¶ added in v0.7.0
func NewProbeError(errorType ErrorType, operation, message string, cause error) *ProbeError
NewProbeError creates a new ProbeError
func (*ProbeError) Error ¶ added in v0.7.0
func (e *ProbeError) Error() string
func (*ProbeError) Is ¶ added in v0.7.0
func (e *ProbeError) Is(target error) bool
func (*ProbeError) Unwrap ¶ added in v0.7.0
func (e *ProbeError) Unwrap() error
func (*ProbeError) WithContext ¶ added in v0.7.0
func (e *ProbeError) WithContext(key string, value interface{}) *ProbeError
WithContext adds context information to the error
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 Result ¶ added in v0.8.0
Result manages execution results for multiple jobs
func (*Result) AddStepResult ¶ added in v0.8.0
func (rs *Result) AddStepResult(jobID string, stepResult StepResult)
AddStepResult adds a StepResult to the specified job result
type StatusType ¶ added in v0.6.0
type StatusType int
StatusType represents the status of execution
const ( StatusSuccess StatusType = iota StatusError StatusWarning StatusSkipped )
type Step ¶
type Step struct {
Name string `yaml:"name"`
ID string `yaml:"id,omitempty"`
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"`
Wait string `yaml:"wait,omitempty"`
SkipIf string `yaml:"skipif,omitempty"`
Outputs map[string]string `yaml:"outputs,omitempty"`
// contains filtered or unexported fields
}
func (*Step) Do ¶ added in v0.5.0
func (st *Step) Do(jCtx *JobContext)
func (*Step) DoEcho ¶ added in v0.5.0
func (st *Step) DoEcho(jCtx *JobContext)
func (*Step) DoEchoWithSequentialPrint ¶ added in v0.5.0
func (st *Step) DoEchoWithSequentialPrint(jCtx *JobContext)
func (*Step) DoTestWithSequentialPrint ¶ added in v0.5.0
func (st *Step) DoTestWithSequentialPrint(jCtx *JobContext) bool
func (*Step) ShowRequestResponse ¶ added in v0.5.0
func (st *Step) ShowRequestResponse(name string, jCtx *JobContext)
type StepContext ¶ added in v0.5.0
type StepContext struct {
Vars map[string]any `expr:"vars"`
Logs []map[string]any `expr:"steps"`
Res map[string]any `expr:"res"`
Req map[string]any `expr:"req"`
RT string `expr:"rt"`
Outputs map[string]map[string]any `expr:"outputs"`
}
StepContext provides context data for step expression evaluation
type StepRepeatCounter ¶ added in v0.6.0
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
WaitTime string
TestOutput string
EchoOutput string
HasTest bool
RepeatCounter *StepRepeatCounter // For repeat execution information
}
StepResult represents the result of a step execution
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError for validation-specific errors
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
}