cli

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoContainerWithOfeliaEnabled = errors.New("couldn't find containers with label 'ofelia.enabled=true'")

Functions

func ApplyLogLevel added in v0.8.0

func ApplyLogLevel(level string) error

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"`
	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"`
		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"`
	}
	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
	// contains filtered or unexported fields
}

Config contains the configuration

func BuildFromFile

func BuildFromFile(filename string, logger core.Logger) (*Config, error)

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 BuildFromString

func BuildFromString(configStr string, logger core.Logger) (*Config, error)

func NewConfig

func NewConfig(logger core.Logger) *Config

func (*Config) InitializeApp

func (c *Config) InitializeApp() error

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"`

	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"`
	PollInterval   time.Duration `mapstructure:"poll-interval" default:"10s"`
	UseEvents      bool          `mapstructure:"events" default:"false"`
	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.

func (*DockerHandler) Shutdown added in v0.8.0

func (c *DockerHandler) Shutdown(ctx context.Context) error

type DoctorCommand added in v0.11.1

type DoctorCommand struct {
	ConfigFile string `long:"config" description:"Path to configuration file" default:"/etc/ofelia/config.ini"`
	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
}

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"`
	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 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.

const (
	JobSourceINI   JobSource = "ini"
	JobSourceLabel JobSource = "label"
)

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"`
	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"`
	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"`
	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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL