refactor: python -> go
All checks were successful
ci/woodpecker/tag/release Pipeline was successful

This commit is contained in:
Felipe M 2025-04-20 13:54:22 +02:00
parent 9c78ea2d48
commit 7c684af8c3
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
79 changed files with 3594 additions and 3257 deletions

59
internal/config/config.go Normal file
View file

@ -0,0 +1,59 @@
package config
import (
"os"
"strings"
)
// Config holds all application configuration
type Config struct {
Debug bool
Hostname string
Port string
LogLevel string
SecretKey string
DatabasePath string
SlackConfig SlackConfig
TelegramConfig TelegramConfig
}
// SlackConfig holds Slack platform configuration
type SlackConfig struct {
Token string
BotOAuthAccessToken string
}
// TelegramConfig holds Telegram platform configuration
type TelegramConfig struct {
Token string
}
// Load loads configuration from environment variables
func Load() (*Config, error) {
config := &Config{
Debug: getEnv("DEBUG", "n") == "y",
Hostname: getEnv("BUTTERROBOT_HOSTNAME", "butterrobot-dev.int.fmartingr.network"),
Port: getEnv("PORT", "8080"),
LogLevel: getEnv("LOG_LEVEL", "ERROR"),
SecretKey: getEnv("SECRET_KEY", "1234"),
DatabasePath: getEnv("DATABASE_PATH", "butterrobot.db"),
SlackConfig: SlackConfig{
Token: getEnv("SLACK_TOKEN", ""),
BotOAuthAccessToken: getEnv("SLACK_BOT_OAUTH_ACCESS_TOKEN", ""),
},
TelegramConfig: TelegramConfig{
Token: getEnv("TELEGRAM_TOKEN", ""),
},
}
return config, nil
}
// getEnv retrieves an environment variable value or returns a default value
func getEnv(key, defaultValue string) string {
value := os.Getenv(key)
if strings.TrimSpace(value) == "" {
return defaultValue
}
return value
}