Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyLogLevel(level string) error
- type CheckResult
- type ComposeJobConfig
- type Config
- type ConfigShowCommand
- type DaemonCommand
- type DockerConfig
- type DockerHandler
- type DoctorCommand
- type DoctorReport
- type ExecJobConfig
- type HashPasswordCommand
- type InitCommand
- type JobSource
- type JobWebhookConfig
- type LocalJobConfig
- type ProgressIndicator
- type ProgressReporter
- type RunJobConfig
- type RunServiceConfig
- type ValidateCommand
- type WebhookConfigs
Constants ¶
const UserContainerDefault = "default"
UserContainerDefault is the sentinel value that explicitly requests the container's default user, overriding any global default-user setting.
Variables ¶
var ( ErrWebhookNameRequired = errors.New("webhook section must have a name") ErrWebAuthUsername = errors.New("web-auth-enabled requires web-username to be set") ErrWebAuthPassword = errors.New("web-auth-enabled requires web-password-hash to be set") ErrInvalidDockerFilter = errors.New("invalid docker filter format") ErrHealthCheckFailed = errors.New("health check failed") ErrInvalidBcryptCost = errors.New("bcrypt cost out of valid range") ErrPasswordTooShort = errors.New("password must be at least 8 characters") ErrPasswordMismatch = errors.New("passwords do not match") ErrUsernameEmpty = errors.New("username cannot be empty") ErrUsernameTooShort = errors.New("username must be at least 3 characters") ErrJobNameEmpty = errors.New("job name cannot be empty") ErrJobNameInvalid = errors.New("job name must be alphanumeric with hyphens or underscores only") ErrDockerImageEmpty = errors.New("Docker image cannot be empty") ErrCommandEmpty = errors.New("command cannot be empty") ErrScheduleEmpty = errors.New("schedule cannot be empty") )
Validation errors
var ErrNoContainerWithOfeliaEnabled = errors.New("couldn't find containers with label 'ofelia.enabled=true'")
Functions ¶
func ApplyLogLevel ¶ added in v0.8.0
ApplyLogLevel sets the global logging level if level is valid. Returns an error if the level is invalid, with a list of valid options.
Types ¶
type CheckResult ¶ added in v0.11.1
type CheckResult struct {
Category string `json:"category"`
Name string `json:"name"`
Status string `json:"status"` // "pass", "fail", "skip"
Message string `json:"message,omitempty"`
Hints []string `json:"hints,omitempty"`
}
CheckResult represents the result of a single health check
type ComposeJobConfig ¶ added in v0.9.0
type ComposeJobConfig struct {
core.ComposeJob `mapstructure:",squash"`
middlewares.OverlapConfig `mapstructure:",squash"`
middlewares.SlackConfig `mapstructure:",squash"`
middlewares.SaveConfig `mapstructure:",squash"`
middlewares.MailConfig `mapstructure:",squash"`
JobWebhookConfig `mapstructure:",squash"`
JobSource JobSource `json:"-" mapstructure:"-"`
}
func (*ComposeJobConfig) GetJobSource ¶ added in v0.9.0
func (c *ComposeJobConfig) GetJobSource() JobSource
func (*ComposeJobConfig) SetJobSource ¶ added in v0.9.0
func (c *ComposeJobConfig) SetJobSource(s JobSource)
type Config ¶
type Config struct {
Global struct {
middlewares.SlackConfig `mapstructure:",squash"`
middlewares.SaveConfig `mapstructure:",squash"`
middlewares.MailConfig `mapstructure:",squash"`
LogLevel string `gcfg:"log-level" mapstructure:"log-level"`
EnableWeb bool `gcfg:"enable-web" mapstructure:"enable-web" default:"false"`
WebAddr string `gcfg:"web-address" mapstructure:"web-address" default:":8081"`
WebAuthEnabled bool `gcfg:"web-auth-enabled" mapstructure:"web-auth-enabled" default:"false"`
WebUsername string `gcfg:"web-username" mapstructure:"web-username"`
WebPasswordHash string `gcfg:"web-password-hash" mapstructure:"web-password-hash"`
WebSecretKey string `gcfg:"web-secret-key" mapstructure:"web-secret-key"`
WebTokenExpiry int `gcfg:"web-token-expiry" mapstructure:"web-token-expiry" default:"24"`
WebMaxLoginAttempts int `gcfg:"web-max-login-attempts" mapstructure:"web-max-login-attempts" default:"5"`
EnablePprof bool `gcfg:"enable-pprof" mapstructure:"enable-pprof" default:"false"`
PprofAddr string `gcfg:"pprof-address" mapstructure:"pprof-address" default:"127.0.0.1:8080"`
MaxRuntime time.Duration `gcfg:"max-runtime" mapstructure:"max-runtime" default:"24h"`
AllowHostJobsFromLabels bool `gcfg:"allow-host-jobs-from-labels" mapstructure:"allow-host-jobs-from-labels" default:"false"` //nolint:revive
EnableStrictValidation bool `gcfg:"enable-strict-validation" mapstructure:"enable-strict-validation" default:"false"`
// DefaultUser sets the default user for exec/run/service jobs when not specified per-job.
// Set to empty string "" to use the container's default user.
// Default: "nobody" (secure unprivileged user)
DefaultUser string `gcfg:"default-user" mapstructure:"default-user" default:"nobody"`
// NotificationCooldown sets the minimum time between duplicate error notifications.
// When a job fails with the same error, notifications (Slack, email, save) will be
// suppressed until this cooldown period expires. Set to 0 to disable deduplication.
// Default: 0 (disabled - all notifications sent)
NotificationCooldown time.Duration `gcfg:"notification-cooldown" mapstructure:"notification-cooldown" default:"0"`
}
ExecJobs map[string]*ExecJobConfig `gcfg:"job-exec" mapstructure:"job-exec,squash"`
RunJobs map[string]*RunJobConfig `gcfg:"job-run" mapstructure:"job-run,squash"`
ServiceJobs map[string]*RunServiceConfig `gcfg:"job-service-run" mapstructure:"job-service-run,squash"`
LocalJobs map[string]*LocalJobConfig `gcfg:"job-local" mapstructure:"job-local,squash"`
ComposeJobs map[string]*ComposeJobConfig `gcfg:"job-compose" mapstructure:"job-compose,squash"`
Docker DockerConfig
WebhookConfigs *WebhookConfigs
// contains filtered or unexported fields
}
Config contains the configuration
func BuildFromFile ¶
BuildFromFile builds a scheduler using the config from one or multiple files. The filename may include glob patterns. When multiple files are matched, they are parsed in lexical order and merged.
func (*Config) InitializeApp ¶
Call this only once at app init
type ConfigShowCommand ¶ added in v0.11.1
type ConfigShowCommand struct {
ConfigFile string `long:"config" env:"OFELIA_CONFIG" description:"configuration file" default:"/etc/ofelia/config.ini"`
LogLevel string `long:"log-level" env:"OFELIA_LOG_LEVEL" description:"Set log level (overrides config)"`
Logger core.Logger
}
ConfigShowCommand displays the effective runtime configuration
func (*ConfigShowCommand) Execute ¶ added in v0.11.1
func (c *ConfigShowCommand) Execute(_ []string) error
Execute runs the config show command
type DaemonCommand ¶
type DaemonCommand struct {
ConfigFile string `long:"config" env:"OFELIA_CONFIG" default:"/etc/ofelia/config.ini"`
DockerFilters []string `short:"f" long:"docker-filter" env:"OFELIA_DOCKER_FILTER"`
DockerPollInterval *time.Duration `long:"docker-poll-interval" env:"OFELIA_POLL_INTERVAL"`
DockerUseEvents *bool `long:"docker-events" env:"OFELIA_DOCKER_EVENTS"`
DockerNoPoll *bool `long:"docker-no-poll" env:"OFELIA_DOCKER_NO_POLL"`
LogLevel string `long:"log-level" env:"OFELIA_LOG_LEVEL"`
EnablePprof bool `long:"enable-pprof" env:"OFELIA_ENABLE_PPROF"`
PprofAddr string `long:"pprof-address" env:"OFELIA_PPROF_ADDRESS" default:"127.0.0.1:8080"`
EnableWeb bool `long:"enable-web" env:"OFELIA_ENABLE_WEB"`
WebAddr string `long:"web-address" env:"OFELIA_WEB_ADDRESS" default:":8081"`
WebAuthEnabled bool `long:"web-auth-enabled" env:"OFELIA_WEB_AUTH_ENABLED"`
WebUsername string `long:"web-username" env:"OFELIA_WEB_USERNAME"`
WebPasswordHash string `long:"web-password-hash" env:"OFELIA_WEB_PASSWORD_HASH"`
WebSecretKey string `long:"web-secret-key" env:"OFELIA_WEB_SECRET_KEY"`
WebTokenExpiry int `long:"web-token-expiry" env:"OFELIA_WEB_TOKEN_EXPIRY" default:"24"`
WebMaxLoginAttempts int `long:"web-max-login-attempts" env:"OFELIA_WEB_MAX_LOGIN_ATTEMPTS" default:"5"`
Logger core.Logger
// contains filtered or unexported fields
}
DaemonCommand daemon process
func (*DaemonCommand) Config ¶ added in v0.8.0
func (c *DaemonCommand) Config() *Config
Config returns the active configuration used by the daemon.
func (*DaemonCommand) Execute ¶
func (c *DaemonCommand) Execute(_ []string) error
Execute runs the daemon
type DockerConfig ¶ added in v0.6.0
type DockerConfig struct {
Filters []string `mapstructure:"filters"`
// ConfigPollInterval controls how often to check for INI config file changes.
// This is independent of container detection. Set to 0 to disable config file watching.
ConfigPollInterval time.Duration `mapstructure:"config-poll-interval" default:"10s"`
// UseEvents enables Docker event-based container detection (recommended).
// When enabled, Ofelia reacts immediately to container start/stop events.
UseEvents bool `mapstructure:"events" default:"true"`
// DockerPollInterval enables periodic polling for container changes.
// This is a fallback for environments where Docker events don't work reliably.
// Set to 0 (default) to disable explicit container polling.
// WARNING: If both events and polling are enabled, this is usually wasteful.
DockerPollInterval time.Duration `mapstructure:"docker-poll-interval" default:"0"`
// PollingFallback auto-enables container polling if event subscription fails.
// This provides backwards compatibility and resilience.
// Set to 0 to disable auto-fallback (will only log errors on event failure).
// Default is 10s for backwards compatibility.
PollingFallback time.Duration `mapstructure:"polling-fallback" default:"10s"`
// Deprecated: Use ConfigPollInterval and DockerPollInterval instead.
// If set, this value is used for both config and container polling (BC).
PollInterval time.Duration `mapstructure:"poll-interval"`
// Deprecated: Use DockerPollInterval=0 instead.
// If true, disables container polling entirely.
DisablePolling bool `mapstructure:"no-poll" default:"false"`
}
type DockerHandler ¶
type DockerHandler struct {
// contains filtered or unexported fields
}
func NewDockerHandler ¶
func NewDockerHandler( ctx context.Context, notifier dockerLabelsUpdate, logger core.Logger, cfg *DockerConfig, provider core.DockerProvider, ) (*DockerHandler, error)
func (*DockerHandler) GetDockerLabels ¶
func (c *DockerHandler) GetDockerLabels() (map[string]map[string]string, error)
func (*DockerHandler) GetDockerProvider ¶ added in v0.12.0
func (c *DockerHandler) GetDockerProvider() core.DockerProvider
GetDockerProvider returns the DockerProvider interface for SDK-based operations. This is the preferred method for new code using the official Docker SDK.
type DoctorCommand ¶ added in v0.11.1
type DoctorCommand struct {
ConfigFile string `long:"config" description:"Path to configuration file"`
LogLevel string `long:"log-level" env:"OFELIA_LOG_LEVEL" description:"Set log level"`
JSON bool `long:"json" description:"Output results as JSON"`
Logger core.Logger
// contains filtered or unexported fields
}
DoctorCommand runs comprehensive health checks on Ofelia configuration and environment
func (*DoctorCommand) Execute ¶ added in v0.11.1
func (c *DoctorCommand) Execute(_ []string) error
Execute runs all health checks
type DoctorReport ¶ added in v0.11.1
type DoctorReport struct {
Healthy bool `json:"healthy"`
Checks []CheckResult `json:"checks"`
}
DoctorReport contains all health check results
type ExecJobConfig ¶
type ExecJobConfig struct {
core.ExecJob `mapstructure:",squash"`
middlewares.OverlapConfig `mapstructure:",squash"`
middlewares.SlackConfig `mapstructure:",squash"`
middlewares.SaveConfig `mapstructure:",squash"`
middlewares.MailConfig `mapstructure:",squash"`
JobWebhookConfig `mapstructure:",squash"`
JobSource JobSource `json:"-" mapstructure:"-"`
}
ExecJobConfig contains all configuration params needed to build a ExecJob
func (*ExecJobConfig) GetJobSource ¶ added in v0.9.0
func (c *ExecJobConfig) GetJobSource() JobSource
func (*ExecJobConfig) SetJobSource ¶ added in v0.9.0
func (c *ExecJobConfig) SetJobSource(s JobSource)
type HashPasswordCommand ¶ added in v0.17.0
type HashPasswordCommand struct {
Cost int `long:"cost" default:"12" description:"bcrypt cost factor (10-14 recommended)"`
LogLevel string `long:"log-level" env:"OFELIA_LOG_LEVEL" description:"Set log level"`
Logger core.Logger
}
func (*HashPasswordCommand) Execute ¶ added in v0.17.0
func (c *HashPasswordCommand) Execute(_ []string) error
type InitCommand ¶ added in v0.11.1
type InitCommand struct {
Output string `long:"output" short:"o" description:"Output file path" default:"./ofelia.ini"`
LogLevel string `long:"log-level" env:"OFELIA_LOG_LEVEL" description:"Set log level"`
Logger core.Logger
}
InitCommand creates an interactive wizard for generating Ofelia configuration
func (*InitCommand) Execute ¶ added in v0.11.1
func (c *InitCommand) Execute(_ []string) error
Execute runs the interactive configuration wizard
type JobSource ¶ added in v0.9.0
type JobSource string
JobSource indicates where a job configuration originated from.
type JobWebhookConfig ¶ added in v0.16.0
type JobWebhookConfig struct {
// Webhooks is a comma-separated list of webhook names for this job
Webhooks string `gcfg:"webhooks" mapstructure:"webhooks"`
}
JobWebhookConfig holds per-job webhook configuration
func (*JobWebhookConfig) GetWebhookNames ¶ added in v0.16.0
func (c *JobWebhookConfig) GetWebhookNames() []string
GetWebhookNames returns the list of webhook names for a job
type LocalJobConfig ¶
type LocalJobConfig struct {
core.LocalJob `mapstructure:",squash"`
middlewares.OverlapConfig `mapstructure:",squash"`
middlewares.SlackConfig `mapstructure:",squash"`
middlewares.SaveConfig `mapstructure:",squash"`
middlewares.MailConfig `mapstructure:",squash"`
JobWebhookConfig `mapstructure:",squash"`
JobSource JobSource `json:"-" mapstructure:"-"`
}
LocalJobConfig contains all configuration params needed to build a RunJob
func (*LocalJobConfig) GetJobSource ¶ added in v0.9.0
func (c *LocalJobConfig) GetJobSource() JobSource
func (*LocalJobConfig) SetJobSource ¶ added in v0.9.0
func (c *LocalJobConfig) SetJobSource(s JobSource)
type ProgressIndicator ¶ added in v0.11.1
type ProgressIndicator struct {
// contains filtered or unexported fields
}
ProgressIndicator provides visual feedback for long-running operations
func NewProgressIndicator ¶ added in v0.11.1
func NewProgressIndicator(logger core.Logger, message string) *ProgressIndicator
NewProgressIndicator creates a new progress indicator If output is not a terminal (e.g., piped to file), it uses simple log messages instead of spinners
func (*ProgressIndicator) Start ¶ added in v0.11.1
func (p *ProgressIndicator) Start()
Start begins displaying the progress indicator
func (*ProgressIndicator) Stop ¶ added in v0.11.1
func (p *ProgressIndicator) Stop(success bool, resultMsg string)
Stop stops the progress indicator and shows completion message
func (*ProgressIndicator) Update ¶ added in v0.11.1
func (p *ProgressIndicator) Update(newMessage string)
Update changes the progress message (for multi-step operations)
type ProgressReporter ¶ added in v0.11.1
type ProgressReporter struct {
// contains filtered or unexported fields
}
ProgressReporter provides structured progress reporting for multi-step operations
func NewProgressReporter ¶ added in v0.11.1
func NewProgressReporter(logger core.Logger, totalSteps int) *ProgressReporter
NewProgressReporter creates a new multi-step progress reporter
func (*ProgressReporter) Complete ¶ added in v0.11.1
func (pr *ProgressReporter) Complete(message string)
Complete marks all steps as complete
func (*ProgressReporter) Step ¶ added in v0.11.1
func (pr *ProgressReporter) Step(stepNum int, message string)
Step reports progress for a single step
type RunJobConfig ¶
type RunJobConfig struct {
core.RunJob `mapstructure:",squash"`
middlewares.OverlapConfig `mapstructure:",squash"`
middlewares.SlackConfig `mapstructure:",squash"`
middlewares.SaveConfig `mapstructure:",squash"`
middlewares.MailConfig `mapstructure:",squash"`
JobWebhookConfig `mapstructure:",squash"`
JobSource JobSource `json:"-" mapstructure:"-"`
}
func (*RunJobConfig) GetJobSource ¶ added in v0.9.0
func (c *RunJobConfig) GetJobSource() JobSource
func (*RunJobConfig) Hash ¶ added in v0.10.1
func (c *RunJobConfig) Hash() (string, error)
Hash overrides BareJob.Hash() to include RunJob-specific fields
func (*RunJobConfig) SetJobSource ¶ added in v0.9.0
func (c *RunJobConfig) SetJobSource(s JobSource)
type RunServiceConfig ¶
type RunServiceConfig struct {
core.RunServiceJob `mapstructure:",squash"`
middlewares.OverlapConfig `mapstructure:",squash"`
middlewares.SlackConfig `mapstructure:",squash"`
middlewares.SaveConfig `mapstructure:",squash"`
middlewares.MailConfig `mapstructure:",squash"`
JobWebhookConfig `mapstructure:",squash"`
JobSource JobSource `json:"-" mapstructure:"-"`
}
RunServiceConfig contains all configuration params needed to build a RunJob
func (*RunServiceConfig) GetJobSource ¶ added in v0.9.0
func (c *RunServiceConfig) GetJobSource() JobSource
func (*RunServiceConfig) SetJobSource ¶ added in v0.9.0
func (c *RunServiceConfig) SetJobSource(s JobSource)
type ValidateCommand ¶
type ValidateCommand struct {
ConfigFile string `long:"config" env:"OFELIA_CONFIG" description:"configuration file" default:"/etc/ofelia/config.ini"`
LogLevel string `long:"log-level" env:"OFELIA_LOG_LEVEL" description:"Set log level (overrides config)"`
Logger core.Logger
}
ValidateCommand validates the config file
func (*ValidateCommand) Execute ¶
func (c *ValidateCommand) Execute(_ []string) error
Execute runs the validation command
type WebhookConfigs ¶ added in v0.16.0
type WebhookConfigs struct {
Global *middlewares.WebhookGlobalConfig
Webhooks map[string]*middlewares.WebhookConfig
Manager *middlewares.WebhookManager
}
WebhookConfigs holds all parsed webhook configurations
func NewWebhookConfigs ¶ added in v0.16.0
func NewWebhookConfigs() *WebhookConfigs
NewWebhookConfigs creates a new WebhookConfigs with defaults
func (*WebhookConfigs) InitManager ¶ added in v0.16.0
func (wc *WebhookConfigs) InitManager() error
InitManager initializes the webhook manager with the parsed configurations