cli

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 22 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)

ApplyLogLevel sets the global logging level if level is valid.

Types

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"`
	}
	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(config 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 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,
	client dockerClient,
) (*DockerHandler, error)

func (*DockerHandler) GetDockerLabels

func (c *DockerHandler) GetDockerLabels() (map[string]map[string]string, error)

func (*DockerHandler) GetInternalDockerClient

func (c *DockerHandler) GetInternalDockerClient() *docker.Client

TODO: Implement an interface so the code does not have to use third parties directly

func (*DockerHandler) Shutdown added in v0.8.0

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

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 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 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) 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