config

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFolder = "./config/"
)

Variables

This section is empty.

Functions

func ConfigLoaded

func ConfigLoaded() bool

func DisableAllJobs

func DisableAllJobs()

func EnableAllJobs

func EnableAllJobs()

func EnableNonScheduledJobs

func EnableNonScheduledJobs()

func EnableScheduledJobs

func EnableScheduledJobs()

func GetAllCrons

func GetAllCrons() map[string][]Job

func GetCommandsByJobName

func GetCommandsByJobName(name string) []string

func GetDeleteRunsAfterDays

func GetDeleteRunsAfterDays() int

func GetJobsCron

func GetJobsCron(job *Job) string

func GetLogLevel

func GetLogLevel() slog.Level

func GetServer

func GetServer() string

func New

func New()

func ToggleDisabledJob

func ToggleDisabledJob(name string) error

func ValidateAndLoadConfig

func ValidateAndLoadConfig(v *viper.Viper) error

Types

type AllowedCommands

type AllowedCommands struct {
	AllowAllArgs bool     `mapstructure:"allow_all_args"`
	Args         []string `mapstructure:"args"`
	// New field to store pre-processed arguments
	AllowedArgsMap map[string]struct{}
}

type Env

type Env struct {
	Key   string `mapstructure:"key" validate:"required"`
	Value string `mapstructure:"value" validate:"required"`
}

type GlobalConfig

type GlobalConfig struct {
	LogLevel            string           `mapstructure:"log_level" validate:"omitempty,oneof=debug info warn error"`
	TimeZone            string           `mapstructure:"time_zone" validate:"omitempty,timezone"`
	DeleteRunsAfterDays int              `mapstructure:"delete_runs_after_days" validate:"gte=0"`
	Jobs                []Job            `mapstructure:"jobs" validate:"omitempty,dive"`
	JobDefaults         JobDefaults      `mapstructure:"job_defaults"`
	Healthcheck         HealthCheck      `mapstructure:"healthcheck" validate:"omitempty"`
	Server              ServerSettings   `mapstructure:"server"`
	Terminal            TerminalSettings `mapstructure:"terminal" validate:"omitempty"`
	Software            []Software       `mapstructure:"software" validate:"omitempty,dive"`
}

type HealthCheck

type HealthCheck struct {
	Authorization string `mapstructure:"authorization"`
	Type          string `mapstructure:"type" validate:"omitempty,oneof=HEAD GET POST"`
	Start         Url    `mapstructure:"start" validate:"omitempty"`
	End           Url    `mapstructure:"end" validate:"omitempty"`
	Failure       Url    `mapstructure:"failure" validate:"omitempty"`
}

func GetHealthcheck

func GetHealthcheck() HealthCheck

type Job

type Job struct {
	Name            string   `mapstructure:"name" validate:"required" json:"name"`
	Cron            string   `mapstructure:"cron" validate:"omitempty,cron" json:"cron"`
	DisableCron     bool     `mapstructure:"disable_cron" json:"disable_cron"`
	DisableFailFast bool     `mapstructure:"disable_fail_fast" json:"disable_fail_fast"`
	Envs            []Env    `mapstructure:"envs" validate:"dive" json:"-"`
	Commands        []string `mapstructure:"commands" validate:"required" json:"-"`
	Disabled        bool     `json:"disabled"`
}

func GetJobByName

func GetJobByName(name string) *Job

func GetJobs

func GetJobs() []Job

type JobDefaults

type JobDefaults struct {
	Cron         string   `mapstructure:"cron" validate:"omitempty,cron"`
	Envs         []Env    `mapstructure:"envs" validate:"dive"`
	PreCommands  []string `mapstructure:"pre_commands"`
	PostCommands []string `mapstructure:"post_commands"`
}

type OrderedEnvs

type OrderedEnvs struct {
	Order []string
	Data  map[string]string
}

func GetEnvsByJobName

func GetEnvsByJobName(name string) OrderedEnvs

type ServerSettings

type ServerSettings struct {
	Address string `mapstructure:"address" validate:"required,ipv4"`
	Port    int    `mapstructure:"port" validate:"required,gte=1024,lte=65535"`
}

type Software

type Software struct {
	Name    string `mapstructure:"name" validate:"required"`
	Version string `mapstructure:"version"`
}

type TerminalSettings

type TerminalSettings struct {
	AllowAllCommands bool                       `mapstructure:"allow_all_commands"`
	AllowedCommands  map[string]AllowedCommands `mapstructure:"allowed_commands" validate:"required_if=AllowAllCommands false,dive"`
}

func GetTerminalSettings

func GetTerminalSettings() TerminalSettings

func (*TerminalSettings) Hydrate

func (s *TerminalSettings) Hydrate()

type Url

type Url struct {
	Url    string         `mapstructure:"url" validate:"required,url"`
	Params map[string]any `mapstructure:"params"`
	Body   string         `mapstructure:"body"`
}

Jump to

Keyboard shortcuts

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