cli

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: MIT Imports: 19 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 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"`
	}
	ExecJobs     map[string]*ExecJobConfig `gcfg:"job-exec" mapstructure:"job-exec,squash"`
	RunJobs      map[string]*RunJobConfig  `gcfg:"job-run" mapstructure:"job-run,squash"`
	LabelRunJobs map[string]*RunJobConfig
	ServiceJobs  map[string]*RunServiceConfig `gcfg:"job-service-run" mapstructure:"job-service-run,squash"`
	LocalJobs    map[string]*LocalJobConfig   `gcfg:"job-local" mapstructure:"job-local,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 a file

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" description:"configuration file" default:"/etc/ofelia/config.ini"`
	DockerFilters      []string       `short:"f" long:"docker-filter" env:"OFELIA_DOCKER_FILTER" description:"Filter for docker containers"`
	DockerPollInterval *time.Duration `long:"docker-poll-interval" env:"OFELIA_POLL_INTERVAL" description:"Interval for docker polling and INI reload (0 disables)"`
	DockerUseEvents    *bool          `long:"docker-events" env:"OFELIA_DOCKER_EVENTS" description:"Use docker events instead of polling"`
	DockerNoPoll       *bool          `long:"docker-no-poll" env:"OFELIA_DOCKER_NO_POLL" description:"Disable polling docker for labels"`
	LogLevel           string         `long:"log-level" env:"OFELIA_LOG_LEVEL" description:"Set log level (overrides config)"`
	EnablePprof        bool           `long:"enable-pprof" env:"OFELIA_ENABLE_PPROF" description:"Enable the pprof HTTP server"`
	PprofAddr          string         `` /* 133-byte string literal not displayed */
	EnableWeb          bool           `long:"enable-web" env:"OFELIA_ENABLE_WEB" description:"Enable the web UI"`
	WebAddr            string         `long:"web-address" env:"OFELIA_WEB_ADDRESS" description:"Address for the web UI HTTP server to listen on" 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(args []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"`
}

ExecJobConfig contains all configuration params needed to build a ExecJob

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

LocalJobConfig contains all configuration params needed to build a RunJob

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

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

RunServiceConfig contains all configuration params needed to build a RunJob

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(args []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