Documentation
¶
Index ¶
- func Install() error
- type BootConfig
- type BootDetector
- type BootTrigger
- func (s *BootTrigger) Always() []string
- func (s *BootTrigger) Check(ctx context.Context) (bool, error)
- func (s *BootTrigger) Name() string
- func (s *BootTrigger) OnFailure() []string
- func (s *BootTrigger) OnSuccess() []string
- func (s *BootTrigger) Run(ctx context.Context) error
- func (s *BootTrigger) Type() string
- type Config
- type ConfigBlock
- type CountConfig
- type CountUnit
- type CronConfig
- type CronTrigger
- func (c *CronTrigger) Always() []string
- func (c *CronTrigger) Check(ctx context.Context) (bool, error)
- func (c *CronTrigger) Name() string
- func (c *CronTrigger) OnFailure() []string
- func (c *CronTrigger) OnSuccess() []string
- func (c *CronTrigger) Run(ctx context.Context) error
- func (c *CronTrigger) Type() string
- type EmailConfig
- type EmailUnit
- func (e *EmailUnit) Always() []string
- func (e *EmailUnit) Name() string
- func (e *EmailUnit) OnFailure() []string
- func (e *EmailUnit) OnSuccess() []string
- func (e *EmailUnit) Run(ctx context.Context) error
- func (e *EmailUnit) SetOutput(output string)
- func (e *EmailUnit) SetTriggerError(err error)
- func (e *EmailUnit) SetTriggeringUnit(unitName string)
- func (e *EmailUnit) Type() string
- type FileConfig
- type FileTrigger
- func (f *FileTrigger) Always() []string
- func (f *FileTrigger) Check(ctx context.Context) (bool, error)
- func (f *FileTrigger) Name() string
- func (f *FileTrigger) OnFailure() []string
- func (f *FileTrigger) OnSuccess() []string
- func (f *FileTrigger) Run(ctx context.Context) error
- func (f *FileTrigger) Type() string
- type GitConfig
- type GitTrigger
- func (g *GitTrigger) Always() []string
- func (g *GitTrigger) Check(ctx context.Context) (bool, error)
- func (g *GitTrigger) Name() string
- func (g *GitTrigger) OnFailure() []string
- func (g *GitTrigger) OnSuccess() []string
- func (g *GitTrigger) Run(ctx context.Context) error
- func (g *GitTrigger) Type() string
- type LogConfig
- type LogUnit
- func (l *LogUnit) Always() []string
- func (l *LogUnit) Name() string
- func (l *LogUnit) OnFailure() []string
- func (l *LogUnit) OnSuccess() []string
- func (l *LogUnit) Run(ctx context.Context) error
- func (l *LogUnit) SetOutput(output string)
- func (l *LogUnit) SetTriggeringUnit(unitName string)
- func (l *LogUnit) Type() string
- type Orchestrator
- type RebootConfig
- type RebootUnit
- type RunConfig
- type RunUnit
- type StartConfig
- type StartTrigger
- func (s *StartTrigger) Always() []string
- func (s *StartTrigger) Check(ctx context.Context) (bool, error)
- func (s *StartTrigger) Name() string
- func (s *StartTrigger) OnFailure() []string
- func (s *StartTrigger) OnSuccess() []string
- func (s *StartTrigger) Run(ctx context.Context) error
- func (s *StartTrigger) Type() string
- type State
- type TriggerUnit
- type Unit
- type UnitConfig
- type UnitConfigWrapper
- type UnitResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BootConfig ¶
type BootConfig struct {
UnitConfig `yaml:",inline"`
}
BootConfig represents the configuration for a boot trigger
type BootDetector ¶
type BootDetector struct {
// contains filtered or unexported fields
}
BootDetector detects system boot time and tracks whether this is the first run since boot
func NewBootDetector ¶
func NewBootDetector(stateFile string) *BootDetector
NewBootDetector creates a new boot detector with the given state file path
func (*BootDetector) GetBootTime ¶
func (bd *BootDetector) GetBootTime() (time.Time, error)
GetBootTime returns the system boot time by reading /proc/uptime
func (*BootDetector) IsFirstRunSinceBoot ¶
func (bd *BootDetector) IsFirstRunSinceBoot() (bool, error)
IsFirstRunSinceBoot checks if this is the first run since system boot It compares the current boot time with the stored boot time from the last run
type BootTrigger ¶
type BootTrigger struct {
// contains filtered or unexported fields
}
BootTrigger is a trigger unit that fires on the first run after system boot
func NewBootTrigger ¶
func NewBootTrigger(name string, state *State, onSuccess, onFailure, always []string) *BootTrigger
NewBootTrigger creates a new boot trigger unit
func (*BootTrigger) Always ¶
func (s *BootTrigger) Always() []string
Always returns the list of units to trigger regardless of success/failure
func (*BootTrigger) Check ¶
func (s *BootTrigger) Check(ctx context.Context) (bool, error)
Check returns true if this is the first run since system boot
func (*BootTrigger) OnFailure ¶
func (s *BootTrigger) OnFailure() []string
OnFailure returns the list of units to trigger on failure
func (*BootTrigger) OnSuccess ¶
func (s *BootTrigger) OnSuccess() []string
OnSuccess returns the list of units to trigger on success
type Config ¶
type Config struct {
ConfigBlock ConfigBlock `yaml:"config"`
Units []UnitConfigWrapper `yaml:"units"`
}
Config represents the SimplCI configuration file
func LoadConfig ¶
LoadConfig loads a configuration file from the given path
func (*Config) CreateUnits ¶
CreateUnits creates unit instances from the configuration
type ConfigBlock ¶
type ConfigBlock struct {
StateLocation string `yaml:"state_location"`
}
ConfigBlock represents the config section of the configuration file
type CountConfig ¶
type CountConfig struct {
UnitConfig `yaml:",inline"`
}
CountConfig represents the configuration for a Count unit
type CountUnit ¶
type CountUnit struct {
// contains filtered or unexported fields
}
CountUnit tracks how many times it has been triggered by each unit
func NewCountUnit ¶
NewCountUnit creates a new Count unit
func (*CountUnit) SetTriggeringUnit ¶
SetTriggeringUnit sets the name of the unit that triggered this count
type CronConfig ¶
type CronConfig struct {
UnitConfig `yaml:",inline"`
Schedule string `yaml:"schedule"`
}
CronConfig represents the configuration for a cron trigger
type CronTrigger ¶
type CronTrigger struct {
// contains filtered or unexported fields
}
CronTrigger is a trigger unit that fires based on a cron schedule
func NewCronTrigger ¶
func NewCronTrigger(name, schedule string, state *State, onSuccess, onFailure, always []string) *CronTrigger
NewCronTrigger creates a new cron trigger unit
func (*CronTrigger) Always ¶
func (c *CronTrigger) Always() []string
Always returns the list of units to trigger regardless of success/failure
func (*CronTrigger) Check ¶
func (c *CronTrigger) Check(ctx context.Context) (bool, error)
Check returns true if the cron schedule has triggered since the last execution
func (*CronTrigger) OnFailure ¶
func (c *CronTrigger) OnFailure() []string
OnFailure returns the list of units to trigger on failure
func (*CronTrigger) OnSuccess ¶
func (c *CronTrigger) OnSuccess() []string
OnSuccess returns the list of units to trigger on success
type EmailConfig ¶
type EmailConfig struct {
UnitConfig `yaml:",inline"`
To []string `yaml:"to"`
From string `yaml:"from"`
SubjectPrefix string `yaml:"subject_prefix,omitempty"`
SMTPHost string `yaml:"smtp_host"`
SMTPPort int `yaml:"smtp_port,omitempty"`
SMTPUser string `yaml:"smtp_user,omitempty"`
SMTPPassword string `yaml:"smtp_password,omitempty"`
SMTPUseTLS *bool `yaml:"smtp_use_tls,omitempty"`
IncludeOutput *bool `yaml:"include_output,omitempty"`
}
EmailConfig represents the configuration for an Email unit
type EmailUnit ¶
type EmailUnit struct {
// contains filtered or unexported fields
}
EmailUnit sends email notifications
func NewEmailUnit ¶
func NewEmailUnit(name string, to []string, from, subjectPrefix, smtpHost string, smtpPort int, smtpUser, smtpPassword string, smtpUseTLS, includeOutput bool, onSuccess, onFailure, always []string) *EmailUnit
NewEmailUnit creates a new Email unit
func (*EmailUnit) SetTriggerError ¶
SetTriggerError sets the error from the triggering unit
func (*EmailUnit) SetTriggeringUnit ¶
SetTriggeringUnit sets the name of the unit that triggered this email
type FileConfig ¶
type FileConfig struct {
UnitConfig `yaml:",inline"`
Pattern string `yaml:"pattern"`
}
FileConfig represents the configuration for a file trigger
type FileTrigger ¶
type FileTrigger struct {
// contains filtered or unexported fields
}
FileTrigger is a trigger unit that fires when files matching a pattern change
func NewFileTrigger ¶
func NewFileTrigger(name, pattern string, state *State, onSuccess, onFailure, always []string) *FileTrigger
NewFileTrigger creates a new file trigger unit
func (*FileTrigger) Always ¶
func (f *FileTrigger) Always() []string
Always returns the list of units to trigger regardless of success/failure
func (*FileTrigger) Check ¶
func (f *FileTrigger) Check(ctx context.Context) (bool, error)
Check returns true if files matching the pattern have changed
func (*FileTrigger) OnFailure ¶
func (f *FileTrigger) OnFailure() []string
OnFailure returns the list of units to trigger on failure
func (*FileTrigger) OnSuccess ¶
func (f *FileTrigger) OnSuccess() []string
OnSuccess returns the list of units to trigger on success
type GitConfig ¶
type GitConfig struct {
UnitConfig `yaml:",inline"`
Repository string `yaml:"repository"`
}
GitConfig represents the configuration for a git trigger
type GitTrigger ¶
type GitTrigger struct {
// contains filtered or unexported fields
}
GitTrigger is a trigger unit that fires when git repository changes are detected
func NewGitTrigger ¶
func NewGitTrigger(name, repository string, state *State, onSuccess, onFailure, always []string) *GitTrigger
NewGitTrigger creates a new git trigger unit
func (*GitTrigger) Always ¶
func (g *GitTrigger) Always() []string
Always returns the list of units to trigger regardless of success/failure
func (*GitTrigger) Check ¶
func (g *GitTrigger) Check(ctx context.Context) (bool, error)
Check returns true if the git repository has new commits since last check
func (*GitTrigger) OnFailure ¶
func (g *GitTrigger) OnFailure() []string
OnFailure returns the list of units to trigger on failure
func (*GitTrigger) OnSuccess ¶
func (g *GitTrigger) OnSuccess() []string
OnSuccess returns the list of units to trigger on success
type LogConfig ¶
type LogConfig struct {
UnitConfig `yaml:",inline"`
File string `yaml:"file"`
}
LogConfig represents the configuration for a Log unit
type LogUnit ¶
type LogUnit struct {
// contains filtered or unexported fields
}
LogUnit writes log messages to a file
func NewLogUnit ¶
NewLogUnit creates a new Log unit
func (*LogUnit) SetTriggeringUnit ¶
SetTriggeringUnit sets the name of the unit that triggered this log
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator manages unit execution and triggering
func NewOrchestrator ¶
func NewOrchestrator(units []Unit) *Orchestrator
NewOrchestrator creates a new orchestrator with the given units
func (*Orchestrator) GetResults ¶
func (o *Orchestrator) GetResults() map[string]*UnitResult
GetResults returns all execution results
func (*Orchestrator) Run ¶
func (o *Orchestrator) Run(ctx context.Context) error
Run executes all units with proper trigger handling (one-time run)
func (*Orchestrator) RunDaemon ¶
func (o *Orchestrator) RunDaemon(ctx context.Context) error
RunDaemon executes in daemon mode, continuously checking triggers
func (*Orchestrator) RunSingleUnit ¶
RunSingleUnit executes a single unit by name If runTriggers is true, the unit runs and all its triggers are executed If runTriggers is false, the unit runs in isolation without executing its triggers
type RebootConfig ¶
type RebootConfig struct {
UnitConfig `yaml:",inline"`
Delay int `yaml:"delay,omitempty"` // delay in seconds before reboot
}
RebootConfig represents the configuration for a reboot unit
type RebootUnit ¶
type RebootUnit struct {
// contains filtered or unexported fields
}
RebootUnit is a unit that logs and reboots the system
func NewRebootUnit ¶
func NewRebootUnit(name string, delay int, onSuccess, onFailure, always []string) *RebootUnit
NewRebootUnit creates a new reboot unit
func (*RebootUnit) Always ¶
func (r *RebootUnit) Always() []string
Always returns the list of units to trigger regardless of success/failure
func (*RebootUnit) OnFailure ¶
func (r *RebootUnit) OnFailure() []string
OnFailure returns the list of units to trigger on failure
func (*RebootUnit) OnSuccess ¶
func (r *RebootUnit) OnSuccess() []string
OnSuccess returns the list of units to trigger on success
type RunConfig ¶
type RunConfig struct {
UnitConfig `yaml:",inline"`
Script string `yaml:"script"`
Directory string `yaml:"directory,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
}
RunConfig represents the configuration for a Run unit
type RunUnit ¶
type RunUnit struct {
// contains filtered or unexported fields
}
RunUnit executes shell scripts/commands
func NewRunUnit ¶
func NewRunUnit(name, script, directory string, timeout time.Duration, onSuccess, onFailure, always []string) *RunUnit
NewRunUnit creates a new Run unit
type StartConfig ¶
type StartConfig struct {
UnitConfig `yaml:",inline"`
}
StartConfig represents the configuration for a Start trigger
type StartTrigger ¶
type StartTrigger struct {
// contains filtered or unexported fields
}
StartTrigger is a trigger that always fires when brun starts
func NewStartTrigger ¶
func NewStartTrigger(name string, onSuccess, onFailure, always []string) *StartTrigger
NewStartTrigger creates a new Start trigger
func (*StartTrigger) Always ¶
func (s *StartTrigger) Always() []string
Always returns the list of units to always trigger
func (*StartTrigger) Check ¶
func (s *StartTrigger) Check(ctx context.Context) (bool, error)
Check always returns true since this trigger fires on every run
func (*StartTrigger) OnFailure ¶
func (s *StartTrigger) OnFailure() []string
OnFailure returns the list of units to trigger on failure
func (*StartTrigger) OnSuccess ¶
func (s *StartTrigger) OnSuccess() []string
OnSuccess returns the list of units to trigger on success
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the common state file for all units
func NewState ¶
NewState creates a new state manager with the given file path filePath must not be empty
type TriggerUnit ¶
type TriggerUnit interface {
Unit
// Check returns true if the trigger condition is met
Check(ctx context.Context) (bool, error)
// OnSuccess returns the names of units to trigger on success
OnSuccess() []string
// OnFailure returns the names of units to trigger on failure
OnFailure() []string
// Always returns the names of units to trigger regardless of success/failure
Always() []string
}
TriggerUnit represents a unit that watches for conditions and triggers other units
type Unit ¶
type Unit interface {
// Name returns the name of the unit
Name() string
// Run executes the unit with the given context
Run(ctx context.Context) error
// Type returns the type of unit (e.g., "trigger", "task")
Type() string
}
Unit represents a unit of work in the CI system
type UnitConfig ¶
type UnitConfig struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
OnSuccess []string `yaml:"on_success,omitempty"`
OnFailure []string `yaml:"on_failure,omitempty"`
Always []string `yaml:"always,omitempty"`
}
UnitConfig represents the base configuration for all units
type UnitConfigWrapper ¶
type UnitConfigWrapper struct {
Start *StartConfig `yaml:"start,omitempty"`
Boot *BootConfig `yaml:"boot,omitempty"`
Reboot *RebootConfig `yaml:"reboot,omitempty"`
Run *RunConfig `yaml:"run,omitempty"`
Log *LogConfig `yaml:"log,omitempty"`
Count *CountConfig `yaml:"count,omitempty"`
Cron *CronConfig `yaml:"cron,omitempty"`
Email *EmailConfig `yaml:"email,omitempty"`
File *FileConfig `yaml:"file,omitempty"`
Git *GitConfig `yaml:"git,omitempty"`
}
UnitConfigWrapper wraps different unit configuration types
type UnitResult ¶
UnitResult represents the result of a unit execution