-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#TODO: unix/tcp socket controller | ||
#TODO: prometheus exporter | ||
|
||
log: | ||
timestamp_format: "2006-01-02T15:04:05.000Z" | ||
format: json | ||
file: ./cron.log | ||
stdout: true | ||
level: debug | ||
|
||
jobs: | ||
backup-database: | ||
description: Backup the production database | ||
enabled: true | ||
exe: | ||
command: /app/backup.sh | ||
scheduler: | ||
cron: "0 0 2 * * *" | ||
retry_delay: 123s | ||
retries: 3 | ||
on_failure: | ||
webhooks: | ||
- address: http://google.com/ | ||
headers: | ||
test: test1 | ||
data: { "job": "@job", "status": "failed" } | ||
env: | ||
DB_HOST: 10.0.0.5 | ||
DB_USER: myuser | ||
DB_PASS: mypassword | ||
metadata: | ||
owner: [email protected] | ||
team: database-team | ||
|
||
# cleanup-logs: | ||
# description: Clean up old log files | ||
# enabled: true | ||
# exe: | ||
# command: /app/cleanup.sh | ||
# scheduler: | ||
# interval: 1h # Run every hour | ||
# retries: 1 | ||
# on_failure: | ||
# exit: true | ||
# webhooks: | ||
# - address: http://google.com/ | ||
# headers: | ||
# test: test1 | ||
# data: { "job": "@job", "status": "failed" } | ||
# metadata: | ||
# owner: [email protected] | ||
# team: devops-team |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Package config contains structured representation of config.yaml file | ||
package config | ||
|
||
import "time" | ||
|
||
type Config struct { | ||
Check failure on line 6 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 6 in config/config.go GitHub Actions / analyze (go)
Check failure on line 6 in config/config.go GitHub Actions / ci (macos-latest)
|
||
Log LogConfig `yaml:"log"` | ||
Jobs map[string]JobConfig `yaml:"jobs"` | ||
} | ||
|
||
type LogConfig struct { | ||
Check failure on line 11 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 11 in config/config.go GitHub Actions / analyze (go)
Check failure on line 11 in config/config.go GitHub Actions / ci (macos-latest)
|
||
TimeStampFormat string `yaml:"timestamp_format"` | ||
Format string `yaml:"format"` | ||
File string `yaml:"file"` | ||
Stdout bool `yaml:"stdout"` | ||
Level string `yaml:"level"` | ||
} | ||
|
||
type JobConfig struct { | ||
Check failure on line 19 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 19 in config/config.go GitHub Actions / analyze (go)
Check failure on line 19 in config/config.go GitHub Actions / ci (macos-latest)
|
||
Description string `yaml:"description"` | ||
Enabled bool `yaml:"enabled"` | ||
Exe JobExe `yaml:"exe"` | ||
Scheduler JobScheduler `yaml:"scheduler"` | ||
Retries int `yaml:"retries"` | ||
RetryDelay time.Duration `yaml:"retry_delay"` | ||
OnFailure JobOnFailure `yaml:"on_failure"` | ||
Env map[string]string `yaml:"env"` | ||
Metadata JobMetadata `yaml:"metadata"` | ||
} | ||
|
||
type JobExe struct { | ||
Check failure on line 31 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 31 in config/config.go GitHub Actions / analyze (go)
Check failure on line 31 in config/config.go GitHub Actions / ci (macos-latest)
|
||
Command string `yaml:"command"` | ||
Args []string `yaml:"args"` | ||
} | ||
|
||
type JobScheduler struct { | ||
Check failure on line 36 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 36 in config/config.go GitHub Actions / analyze (go)
Check failure on line 36 in config/config.go GitHub Actions / ci (macos-latest)
|
||
Cron string `yaml:"cron"` | ||
Interval string `yaml:"interval"` | ||
} | ||
|
||
type JobOnFailure struct { | ||
Check failure on line 41 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 41 in config/config.go GitHub Actions / analyze (go)
Check failure on line 41 in config/config.go GitHub Actions / ci (macos-latest)
|
||
Webhooks []WebHook `yaml:"webhooks"` | ||
ShouldExit bool `yaml:"exit"` | ||
} | ||
type WebHook struct { | ||
Check failure on line 45 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 45 in config/config.go GitHub Actions / analyze (go)
Check failure on line 45 in config/config.go GitHub Actions / ci (macos-latest)
|
||
Address string `yaml:"address"` | ||
Headers map[string]string `yaml:"headers"` | ||
Data map[string]any `yaml:"data"` | ||
} | ||
|
||
type JobMetadata = map[string]string | ||
Check failure on line 51 in config/config.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 51 in config/config.go GitHub Actions / analyze (go)
Check failure on line 51 in config/config.go GitHub Actions / ci (macos-latest)
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Package logger contains basic logging logic of the application | ||
package logger | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func SetupLogger(parent logrus.Entry, section string) *logrus.Entry { | ||
Check failure on line 10 in logger/logger.go GitHub Actions / ci (ubuntu-latest)
Check failure on line 10 in logger/logger.go GitHub Actions / analyze (go)
Check failure on line 10 in logger/logger.go GitHub Actions / ci (macos-latest)
|
||
parentSection := parent.Data["section"] | ||
sectionValue := fmt.Sprintf("%s/%s", parentSection, section) | ||
return parent.WithField("section", sectionValue) | ||
} |