debc4bf78c
Release / build (amd64, darwin) (push) Failing after 2m46s
Release / build (amd64, linux) (push) Failing after 2m26s
Release / build (arm64, darwin) (push) Failing after 1m40s
Release / build (arm64, linux) (push) Failing after 10s
Release / release (push) Has been skipped
Release / chart (push) Failing after 11s
Release / docker (push) Failing after 19s
Alerts can be manually archived (POST /api/alerts/{id}/archive) or
unarchived (DELETE /api/alerts/{id}/archive). A background goroutine
auto-archives resolved alerts older than TERDUT_ARCHIVE_AFTER (default 7d).
GET /api/alerts hides archived alerts by default; ?archived=true shows them.
31 lines
553 B
Go
31 lines
553 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
type Config struct {
|
|
Addr string
|
|
DBPath string
|
|
ArchiveAfter time.Duration
|
|
}
|
|
|
|
func Load() Config {
|
|
addr := os.Getenv("TERDUT_ADDR")
|
|
if addr == "" {
|
|
addr = ":8080"
|
|
}
|
|
dbPath := os.Getenv("TERDUT_DB_PATH")
|
|
if dbPath == "" {
|
|
dbPath = "terdut.db"
|
|
}
|
|
archiveAfter := 7 * 24 * time.Hour
|
|
if s := os.Getenv("TERDUT_ARCHIVE_AFTER"); s != "" {
|
|
if d, err := time.ParseDuration(s); err == nil {
|
|
archiveAfter = d
|
|
}
|
|
}
|
|
return Config{Addr: addr, DBPath: dbPath, ArchiveAfter: archiveAfter}
|
|
}
|