package config import ( "os" "strconv" ) type Config struct { Locale string Token string Webhookurl string Webhooktoken string PageSize int CacheTTL int } func Load() *Config { return &Config{ Locale: getEnv("DOCKERBOT_LOCALE", "en"), Token: getEnv("DOCKERBOT_TOKEN", ""), Webhookurl: getEnv("DOCKERBOT_WEBHOOKURL", ""), Webhooktoken: getEnv("DOCKERBOT_WEBHOOK_TOKEN", ""), PageSize: getEnvInt("DOCKERBOT_PAGE_SIZE", 4), CacheTTL: getEnvInt("DOCKERBOT_CACHE_TTL", 10), } } func getEnv(key, defaultValue string) string { val := os.Getenv(key) if val == "" { return defaultValue } return val } func getEnvInt(key string, defaultValue int) int { valStr := os.Getenv(key) if valStr == "" { return defaultValue } val, err := strconv.Atoi(valStr) if err != nil { return defaultValue } if val <= 0 { return defaultValue } return val } func getEnvBool(key string, defaultValue bool) bool { val := os.Getenv(key) if val == "" { return defaultValue } v, err := strconv.ParseBool(val) if err != nil { return defaultValue } return v }