config

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_DB_PATH = ".corn/corn.sqlite"

sqlite db file path, home path should be added later

View Source
const DEFAULT_LOGS_DIR = ".corn/logs"

logs dir, home path should be added later

View Source
const DEFAULT_NOTIFY_TIMEOUT = 10000

Variables

View Source
var CONFIG_PATHS = []string{
	".config/corn/corn.yaml",
	".config/corn/corn.yml",
}

Functions

func GetConfigPath

func GetConfigPath() (string, error)

Types

type Config

type Config struct {
	DbAddr               string                   `yaml:"dbAddr"`
	Jobs                 map[string]Job           `yaml:"jobs" validate:"required,min=1,dive"`
	Remotes              map[string]Remote        `yaml:"remotes" validate:"dive"`
	Notifiers            map[string]NotifyService `yaml:"notifiers" validate:"dive"`
	LogsDir              string                   `yaml:"logsDir"`
	NotifyTimeoutMs      int                      `yaml:"notifyTimeoutMs"`
	DefaultFailNotifier  string                   `yaml:"defaultFailNotifier"`
	DefaultNotifier      string                   `yaml:"defaultNotifier"`
	DefaultTimeoutS      int                      `yaml:"defaultTimeoutS"`
	DisableNotifications bool                     `yaml:"disableNotifications"`
	Timezone             string                   `yaml:"timezone"`
}

func ParseAndValidateConfig

func ParseAndValidateConfig(configPath string, v *validator.Validate) (*Config, error)

func ParseConfig

func ParseConfig(configPath string) (*Config, error)

type DiscordNotifyService

type DiscordNotifyService struct {
	OAuth2Token string   `yaml:"oAuth2Token"`
	BotToken    string   `yaml:"botToken"`
	Channels    []string `yaml:"channels" validate:"required,min=1"`
}

type FailStrategy

type FailStrategy struct {
	Retry *FailStrategyRetry `yaml:"retry"`
	Halt  *FailStrategyHalt  `yaml:"halt"`
}

type FailStrategyHalt

type FailStrategyHalt struct {
}

type FailStrategyRetry

type FailStrategyRetry struct {
	MaxRetries  uint `yaml:"maxRetries" validate:"required"`
	CoolOffSecs uint `yaml:"coolOffSecs"`
}

type Job

type Job struct {
	Schedules        []string      `yaml:"schedules" validate:"required"`
	Command          string        `yaml:"command" validate:"required"`
	OnlyLogOnFail    bool          `yaml:"onlyLogOnFail"`
	IgnoreStderrLog  bool          `yaml:"ignoreStdErrLog"`
	OnlyNotifyOnFail bool          `yaml:"onlyNotifyOnFail"`
	FailNotifier     string        `yaml:"failNotifier"`
	Notifier         string        `yaml:"notifier"`
	TimeoutS         int           `yaml:"timeoutS"`
	RemoteName       string        `yaml:"remoteName"`
	FailStrategy     *FailStrategy `yaml:"failStrategy"`
}

type KeyAuth

type KeyAuth struct {
	KeyPath    string `yaml:"keyPath" validate:"required"`
	Passphrase string `yaml:"passphrase"`
}

type NotifyService

type NotifyService struct {
	Telegram []TelegramNotifyService `yaml:"telegram"`
	Discord  []DiscordNotifyService  `yaml:"discord"`
}

type PasswordAuth

type PasswordAuth struct {
	Password string `yaml:"password" validate:"required"`
}

type Remote

type Remote struct {
	Username string      `yaml:"username" validate:"required,min=1"`
	Address  string      `yaml:"address" validate:"required,min=1"`
	Port     uint        `yaml:"port" validate:"required"`
	Auth     *RemoteAuth `yaml:"auth" validate:"required"`
}

type RemoteAuth

type RemoteAuth struct {
	PasswordAuth *PasswordAuth `yaml:"passwordAuth"`
	KeyAuth      *KeyAuth      `yaml:"keyAuth"`
}

type TelegramNotifyService

type TelegramNotifyService struct {
	Token     string  `yaml:"token" validate:"required"`
	Receivers []int64 `yaml:"receivers" validate:"required,min=1"`
}

Jump to

Keyboard shortcuts

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