config

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config contains the configuration information of the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Log configs
	LogTimestampFormat string                 `mapstructure:"log_timestamp_format" json:"log_timestamp_format,omitempty"`
	LogFormat          enums.LoggerFormatType `mapstructure:"log_format" json:"log_format,omitempty"`
	LogFile            string                 `mapstructure:"log_file" json:"log_file,omitempty"`
	LogStdout          bool                   `mapstructure:"log_stdout" json:"log_stdout,omitempty"`
	LogLevel           enums.LogLevel         `mapstructure:"log_level" json:"log_level,omitempty"`

	// Command executor configs
	Shell     string   `mapstructure:"shell" json:"shell,omitempty"`
	ShellArgs []string `mapstructure:"shell_args" json:"shell_args,omitempty"`

	// Web-server config
	WebServerAddress  string `mapstructure:"webserver_address" json:"webserver_listen_address,omitempty"`
	WebServerPort     uint   `mapstructure:"webserver_port" json:"webserver_port,omitempty"`
	WebserverUsername string `mapstructure:"webserver_username" json:"webserver_username,omitempty"`
	WebServerPassword string `mapstructure:"webserver_password" json:"webserver_password,omitempty"`
	WebServerMetrics  bool   `mapstructure:"webserver_metrics" json:"webserver_metrics,omitempty"`

	Jobs []*JobConfig `mapstructure:"jobs" json:"jobs"`
}

Config represents the configuration for the crontab application.

func (*Config) Validate

func (cfg *Config) Validate(log *logrus.Entry) error

Validate checks the validity of the Config struct. It ensures that the log format and log level are valid, and all jobs within the config are also valid. If any validation fails, it returns an error with the specific validation error. Otherwise, it returns nil.

type DockerEvent added in v0.6.0

type DockerEvent struct {
	Connection       string                 `mapstructure:"connection" json:"connection,omitempty"`
	Name             string                 `mapstructure:"name" json:"name,omitempty"`
	Image            string                 `mapstructure:"image" json:"image,omitempty"`
	Actions          []string               `mapstructure:"actions" json:"actions,omitempty"`
	Labels           map[string]string      `mapstructure:"labels" json:"labels,omitempty"`
	ErrorLimit       uint                   `mapstructure:"error-limit-count" json:"error-limit,omitempty"`
	ErrorLimitPolicy event.ErrorLimitPolicy `mapstructure:"error-limit-policy" json:"error-limit-policy,omitempty"`
	ErrorThrottle    time.Duration          `mapstructure:"error-throttle" json:"error-throttle,omitempty"`
}

DockerEvent represents a Docker event configuration

type JobConfig

type JobConfig struct {
	Name        string     `mapstructure:"name" json:"name,omitempty"`
	Description string     `mapstructure:"description" json:"description,omitempty"`
	Disabled    bool       `mapstructure:"disabled" json:"disabled,omitempty"`
	Concurrency uint       `mapstructure:"concurrency" json:"concurrency,omitempty"`
	Tasks       []Task     `mapstructure:"tasks" json:"tasks,omitempty"`
	Events      []JobEvent `mapstructure:"events" json:"events"`
	Hooks       JobHooks   `mapstructure:"hooks" json:"hooks,omitempty"`
}

JobConfig represents the configuration for a specific job.

func (*JobConfig) Validate

func (c *JobConfig) Validate(log *logrus.Entry) error

type JobEvent added in v0.4.1

type JobEvent struct {
	Cron     string        `mapstructure:"cron" json:"cron,omitempty"`
	Interval time.Duration `mapstructure:"interval" json:"interval,omitempty"`
	OnInit   bool          `mapstructure:"on-init" json:"on-init,omitempty"`
	WebEvent string        `mapstructure:"web-event" json:"web-event,omitempty"`
	Docker   *DockerEvent  `mapstructure:"docker" json:"docker,omitempty"`
}

JobEvent represents the scheduling configuration for a job.

func (*JobEvent) Validate added in v0.4.1

func (s *JobEvent) Validate(log *logrus.Entry) error

Validate checks the validity of a JobEvent configuration. It ensures that the event has a valid interval or cron expression, and only one of on_init, interval, or cron is set. It returns an error if the validation fails, otherwise, it returns nil.

type JobHooks

type JobHooks struct {
	Done   []Task `mapstructure:"done" json:"done,omitempty"`
	Failed []Task `mapstructure:"failed" json:"failed,omitempty"`
}

JobHooks represents the hooks configuration for a job.

type Task

type Task struct {
	// Http Requests
	Post    string            `mapstructure:"post" json:"post,omitempty"`
	Get     string            `mapstructure:"get" json:"get,omitempty"`
	Headers map[string]string `mapstructure:"headers" json:"headers,omitempty"`
	Data    any               `mapstructure:"data" json:"data,omitempty"`

	// Command params
	Command          string            `mapstructure:"command" json:"command,omitempty"`
	WorkingDirectory string            `mapstructure:"working-dir" json:"working-directory,omitempty"`
	UserName         string            `mapstructure:"user" json:"user,omitempty"`
	GroupName        string            `mapstructure:"group" json:"group,omitempty"`
	Env              map[string]string `mapstructure:"env" json:"env,omitempty"`
	Connections      []TaskConnection  `mapstructure:"connections" json:"connections,omitempty"`

	// Retry & Timeout config
	Retries    uint          `mapstructure:"retries" json:"retries,omitempty"`
	RetryDelay time.Duration `mapstructure:"retry-delay" json:"retry-delay,omitempty"`
	Timeout    time.Duration `mapstructure:"timeout" json:"timeout,omitempty"`

	// Hooks
	OnDone []Task `mapstructure:"on-done" json:"on-done,omitempty"`
	OnFail []Task `mapstructure:"on-fail" json:"on-fail,omitempty"`
}

Task represents the configuration for a task within a job.

func (*Task) Validate

func (t *Task) Validate(log *logrus.Entry) error

Validate checks the validity of a Task. It ensures that the task has exactly one of the Get, Post, or Command fields, and validates other fields based on the specified action. If any validation fails, it returns an error with the specific validation error. Otherwise, it returns nil.

type TaskConnection added in v0.4.1

type TaskConnection struct {
	Local            bool     `mapstructure:"local" json:"local,omitempty"`
	DockerConnection string   `mapstructure:"docker" json:"docker,omitempty"`
	ContainerName    string   `mapstructure:"container" json:"container,omitempty"`
	ImageName        string   `mapstructure:"image" json:"image,omitempty"`
	Volumes          []string `mapstructure:"volumes" json:"volumes,omitempty"`
	Networks         []string `mapstructure:"networks" json:"networks,omitempty"`
}

TaskConnection represents the connection configuration for a task.

Directories

Path Synopsis
Package cfgcompiler provides mapper functions for the config structs
Package cfgcompiler provides mapper functions for the config structs

Jump to

Keyboard shortcuts

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