Documentation
¶
Index ¶
- func CalculateNextRun(cron *CronExpression, after time.Time) (time.Time, error)
- func DescribeCronExpression(cron *CronExpression) string
- type Action
- type ActionType
- type CronExpression
- type Manager
- type Schedule
- type ScheduleStatus
- type StepExecution
- type StepStatus
- type Storage
- func (s *Storage) DeleteSchedule(id string) error
- func (s *Storage) DeleteWorkflow(id string) error
- func (s *Storage) FindScheduleByName(name string) (*Schedule, error)
- func (s *Storage) FindWorkflowByName(name string) (*Workflow, error)
- func (s *Storage) ListSchedules() ([]*Schedule, error)
- func (s *Storage) ListWorkflows() ([]*Workflow, error)
- func (s *Storage) LoadSchedule(id string) (*Schedule, error)
- func (s *Storage) LoadWorkflow(id string) (*Workflow, error)
- func (s *Storage) SaveSchedule(schedule *Schedule) error
- func (s *Storage) SaveWorkflow(workflow *Workflow) error
- type Workflow
- type WorkflowEngine
- type WorkflowExecution
- type WorkflowExecutionStatus
- type WorkflowStep
- type WorkflowTrigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateNextRun ¶
CalculateNextRun calculates the next run time for a cron expression after the given time.
func DescribeCronExpression ¶
func DescribeCronExpression(cron *CronExpression) string
DescribeCronExpression returns a human-readable description of what the cron expression means.
Types ¶
type Action ¶
type Action struct {
Type ActionType `json:"type"`
Config map[string]string `json:"config,omitempty"`
}
Action represents an action to perform after a scan.
type ActionType ¶
type ActionType string
ActionType specifies the type of post-scan action.
const ( ActionReport ActionType = "report" ActionNotify ActionType = "notify" ActionCompare ActionType = "compare" ActionWebhook ActionType = "webhook" ActionSetBaseline ActionType = "set_baseline" )
type CronExpression ¶
type CronExpression struct {
Minute string // 0-59 or *
Hour string // 0-23 or *
DayOfMonth string // 1-31 or *
Month string // 1-12 or *
DayOfWeek string // 0-7 or * (0 and 7 are Sunday)
}
CronExpression represents a parsed cron expression.
func ParseCronExpression ¶
func ParseCronExpression(expr string) (*CronExpression, error)
ParseCronExpression parses a cron expression and returns a CronExpression. Supports standard 5-field cron syntax: minute hour day-of-month month day-of-week Examples:
- "0 2 * * *" = Every day at 2:00 AM
- "*/15 * * * *" = Every 15 minutes
- "0 */2 * * *" = Every 2 hours
- "0 0 1 * *" = First day of every month at midnight
func (*CronExpression) String ¶
func (c *CronExpression) String() string
String returns a human-readable description of the cron expression.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages scheduled scans and workflows.
func NewManager ¶
NewManager creates a new scheduler manager.
func (*Manager) GetScheduleStatus ¶
func (m *Manager) GetScheduleStatus(scheduleID string) (*ScheduleStatus, error)
GetScheduleStatus returns the current status of a schedule.
func (*Manager) ListActiveJobs ¶
ListActiveJobs returns all currently running jobs.
func (*Manager) RunScheduleNow ¶
RunScheduleNow manually triggers a schedule to run immediately.
type Schedule ¶
type Schedule struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
CronExpr string `json:"cron_expr"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastRun *time.Time `json:"last_run,omitempty"`
NextRun *time.Time `json:"next_run,omitempty"`
// Scan configuration
Target string `json:"target"`
Template string `json:"template,omitempty"`
ScanType string `json:"scan_type"` // blitz, raider, full
Options map[string]string `json:"options,omitempty"`
// Actions to perform after scan
Actions []Action `json:"actions,omitempty"`
}
Schedule represents a scheduled scan configuration.
type ScheduleStatus ¶
type ScheduleStatus struct {
Schedule Schedule
IsRunning bool
LastRunTime *time.Time
LastError string
RunCount int
}
ScheduleStatus represents the current status of a schedule.
type StepExecution ¶
type StepExecution struct {
StepName string `json:"step_name"`
Status StepStatus `json:"status"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Error string `json:"error,omitempty"`
Output map[string]interface{} `json:"output,omitempty"`
}
StepExecution represents the execution of a single workflow step.
type StepStatus ¶
type StepStatus string
StepStatus represents the status of a step execution.
const ( StepStatusPending StepStatus = "pending" StepStatusRunning StepStatus = "running" StepStatusCompleted StepStatus = "completed" StepStatusFailed StepStatus = "failed" StepStatusSkipped StepStatus = "skipped" )
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage manages persistent storage of schedules and workflows.
func NewStorage ¶
NewStorage creates a new Storage instance.
func (*Storage) DeleteSchedule ¶
DeleteSchedule deletes a schedule by ID.
func (*Storage) DeleteWorkflow ¶
DeleteWorkflow deletes a workflow by ID.
func (*Storage) FindScheduleByName ¶
FindScheduleByName finds a schedule by name (case-insensitive).
func (*Storage) FindWorkflowByName ¶
FindWorkflowByName finds a workflow by name (case-insensitive).
func (*Storage) ListSchedules ¶
ListSchedules returns all schedules.
func (*Storage) ListWorkflows ¶
ListWorkflows returns all workflows.
func (*Storage) LoadSchedule ¶
LoadSchedule loads a schedule by ID.
func (*Storage) LoadWorkflow ¶
LoadWorkflow loads a workflow by ID.
func (*Storage) SaveSchedule ¶
SaveSchedule persists a schedule to disk.
func (*Storage) SaveWorkflow ¶
SaveWorkflow persists a workflow to disk.
type Workflow ¶
type Workflow struct {
ID string `yaml:"-" json:"id"`
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Enabled bool `yaml:"-" json:"enabled"`
Trigger WorkflowTrigger `yaml:"trigger" json:"trigger"`
Steps []WorkflowStep `yaml:"steps" json:"steps"`
Variables map[string]string `yaml:"variables,omitempty" json:"variables,omitempty"`
CreatedAt time.Time `yaml:"-" json:"created_at"`
UpdatedAt time.Time `yaml:"-" json:"updated_at"`
}
Workflow represents an automated workflow definition.
func LoadWorkflowFromFile ¶
LoadWorkflowFromFile loads a workflow definition from a YAML file.
func ParseWorkflowYAML ¶
ParseWorkflowYAML parses a workflow from YAML data.
type WorkflowEngine ¶
type WorkflowEngine struct {
// contains filtered or unexported fields
}
WorkflowEngine executes workflows.
func NewWorkflowEngine ¶
func NewWorkflowEngine(storage *Storage) *WorkflowEngine
NewWorkflowEngine creates a new workflow engine.
func (*WorkflowEngine) Execute ¶
func (e *WorkflowEngine) Execute(ctx context.Context, workflow *Workflow) (*WorkflowExecution, error)
Execute executes a workflow.
type WorkflowExecution ¶
type WorkflowExecution struct {
ID string `json:"id"`
WorkflowID string `json:"workflow_id"`
Status WorkflowExecutionStatus `json:"status"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Steps []StepExecution `json:"steps"`
Error string `json:"error,omitempty"`
Context map[string]interface{} `json:"context,omitempty"` // Shared context between steps
}
WorkflowExecution represents a workflow execution instance.
type WorkflowExecutionStatus ¶
type WorkflowExecutionStatus string
WorkflowExecutionStatus represents the status of a workflow execution.
const ( ExecutionStatusPending WorkflowExecutionStatus = "pending" ExecutionStatusRunning WorkflowExecutionStatus = "running" ExecutionStatusCompleted WorkflowExecutionStatus = "completed" ExecutionStatusFailed WorkflowExecutionStatus = "failed" ExecutionStatusCancelled WorkflowExecutionStatus = "cancelled" )
type WorkflowStep ¶
type WorkflowStep struct {
Name string `yaml:"name" json:"name"`
Action string `yaml:"action" json:"action"` // scan, compare, notify, report
Condition string `yaml:"condition,omitempty" json:"condition,omitempty"`
Config map[string]string `yaml:"config,omitempty" json:"config,omitempty"`
}
WorkflowStep represents a single step in a workflow.
type WorkflowTrigger ¶
type WorkflowTrigger struct {
Schedule string `yaml:"schedule,omitempty" json:"schedule,omitempty"` // Cron expression
Webhook bool `yaml:"webhook,omitempty" json:"webhook,omitempty"` // Enable webhook trigger
Manual bool `yaml:"manual,omitempty" json:"manual,omitempty"` // Allow manual trigger
}
WorkflowTrigger defines when a workflow should run.