Documentation
¶
Index ¶
- func Install(daemonMode bool) error
- func Update(currentVersion string) error
- type BootConfig
- type BootDetector
- type BootTrigger
- func (s *BootTrigger) Always() []string
- func (s *BootTrigger) Check(ctx context.Context, mode CheckMode) (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 CheckMode
- type Config
- type ConfigBlock
- type CountConfig
- type CountUnit
- type CronConfig
- type CronTrigger
- func (c *CronTrigger) Always() []string
- func (c *CronTrigger) Check(ctx context.Context, mode CheckMode) (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, mode CheckMode) (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 GitHubRelease
- type GitTrigger
- func (g *GitTrigger) Always() []string
- func (g *GitTrigger) Check(ctx context.Context, mode CheckMode) (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 NtfyConfig
- type NtfyUnit
- func (n *NtfyUnit) Always() []string
- func (n *NtfyUnit) Name() string
- func (n *NtfyUnit) OnFailure() []string
- func (n *NtfyUnit) OnSuccess() []string
- func (n *NtfyUnit) Run(ctx context.Context) error
- func (n *NtfyUnit) SetOutput(output string)
- func (n *NtfyUnit) SetTriggerError(err error)
- func (n *NtfyUnit) SetTriggeringUnit(unitName string)
- func (n *NtfyUnit) Type() string
- type Orchestrator
- func (o *Orchestrator) GetActiveUnit() string
- func (o *Orchestrator) GetResults() map[string]*UnitResult
- func (o *Orchestrator) Run() error
- func (o *Orchestrator) RunDaemon(ctx context.Context) error
- func (o *Orchestrator) RunOnce(ctx context.Context) error
- func (o *Orchestrator) RunSingleUnit(ctx context.Context, unitName string, runTriggers bool) error
- func (o *Orchestrator) SetDaemonMode(daemon bool)
- func (o *Orchestrator) Stop(error)
- type RebootConfig
- type RebootUnit
- type RunConfig
- type RunUnit
- type StartConfig
- type StartTrigger
- func (s *StartTrigger) Always() []string
- func (s *StartTrigger) Check(ctx context.Context, mode CheckMode) (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) 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 CheckMode ¶ added in v0.0.17
type CheckMode int
CheckMode indicates how a trigger unit's Check method is being called
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. If the file is encrypted with SOPS, it will be automatically decrypted.
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 ¶
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"`
LimitLines int `yaml:"limit_lines,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, limitLines int, 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) 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"`
Branch string `yaml:"branch"`
Reset bool `yaml:"reset"`
Poll string `yaml:"poll"`
Debug bool `yaml:"debug"`
}
GitConfig represents the configuration for a git trigger
type GitHubRelease ¶ added in v0.0.5
GitHubRelease represents the GitHub API release response
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, branch string, reset bool, pollInterval time.Duration, debug bool, 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 ¶
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 NtfyConfig ¶ added in v0.0.20
type NtfyConfig struct {
UnitConfig `yaml:",inline"`
Topic string `yaml:"topic"`
Server string `yaml:"server,omitempty"`
TitlePrefix string `yaml:"title_prefix,omitempty"`
Priority string `yaml:"priority,omitempty"`
Tags string `yaml:"tags,omitempty"`
IncludeOutput *bool `yaml:"include_output,omitempty"`
LimitLines int `yaml:"limit_lines,omitempty"`
}
NtfyConfig represents the configuration for an Ntfy unit
type NtfyUnit ¶ added in v0.0.20
type NtfyUnit struct {
// contains filtered or unexported fields
}
NtfyUnit sends notifications via ntfy.sh
func NewNtfyUnit ¶ added in v0.0.20
func NewNtfyUnit(name, topic, server, titlePrefix, priority, tags string, includeOutput bool, limitLines int, onSuccess, onFailure, always []string) *NtfyUnit
NewNtfyUnit creates a new Ntfy unit
func (*NtfyUnit) OnFailure ¶ added in v0.0.20
OnFailure returns the list of units to trigger on failure
func (*NtfyUnit) OnSuccess ¶ added in v0.0.20
OnSuccess returns the list of units to trigger on success
func (*NtfyUnit) SetOutput ¶ added in v0.0.20
SetOutput sets the output data from the triggering unit
func (*NtfyUnit) SetTriggerError ¶ added in v0.0.20
SetTriggerError sets the error from the triggering unit
func (*NtfyUnit) SetTriggeringUnit ¶ added in v0.0.20
SetTriggeringUnit sets the name of the unit that triggered this notification
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) GetActiveUnit ¶ added in v0.0.9
func (o *Orchestrator) GetActiveUnit() string
GetActiveUnit returns the name of the currently executing unit, or empty string if none
func (*Orchestrator) GetResults ¶
func (o *Orchestrator) GetResults() map[string]*UnitResult
GetResults returns all execution results
func (*Orchestrator) Run ¶
func (o *Orchestrator) Run() error
Run executes the orchestrator (for use with oklog/run)
func (*Orchestrator) RunDaemon ¶
func (o *Orchestrator) RunDaemon(ctx context.Context) error
RunDaemon executes in daemon mode, continuously checking triggers
func (*Orchestrator) RunOnce ¶ added in v0.0.9
func (o *Orchestrator) RunOnce(ctx context.Context) error
RunOnce executes all units once with the given context This method is useful for testing and one-time execution
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
func (*Orchestrator) SetDaemonMode ¶ added in v0.0.9
func (o *Orchestrator) SetDaemonMode(daemon bool)
SetDaemonMode configures whether the orchestrator should run in daemon mode
func (*Orchestrator) Stop ¶ added in v0.0.9
func (o *Orchestrator) Stop(error)
Stop stops the orchestrator (for use with oklog/run)
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"`
Shell string `yaml:"shell,omitempty"`
UsePTY bool `yaml:"use_pty,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, shell string, usePTY bool, 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) 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
// mode indicates whether this is a polling check or a manual trigger from another unit
Check(ctx context.Context, mode CheckMode) (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 {
Boot *BootConfig `yaml:"boot,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"`
Log *LogConfig `yaml:"log,omitempty"`
Ntfy *NtfyConfig `yaml:"ntfy,omitempty"`
Reboot *RebootConfig `yaml:"reboot,omitempty"`
Run *RunConfig `yaml:"run,omitempty"`
Start *StartConfig `yaml:"start,omitempty"`
}
UnitConfigWrapper wraps different unit configuration types
type UnitResult ¶
UnitResult represents the result of a unit execution