add mosis-portal Go project with package signing and validation
This commit is contained in:
60
portal/internal/config/config.go
Normal file
60
portal/internal/config/config.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Package config handles configuration loading for mosis-portal
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Config holds all configuration for the portal
|
||||
type Config struct {
|
||||
// Server settings
|
||||
ListenAddr string
|
||||
BaseURL string
|
||||
|
||||
// Database
|
||||
DatabasePath string
|
||||
|
||||
// JWT
|
||||
JWTSecret string
|
||||
|
||||
// OAuth2 - GitHub
|
||||
GitHubClientID string
|
||||
GitHubClientSecret string
|
||||
|
||||
// OAuth2 - Google
|
||||
GoogleClientID string
|
||||
GoogleClientSecret string
|
||||
|
||||
// Storage
|
||||
PackagesDir string
|
||||
BackupsDir string
|
||||
}
|
||||
|
||||
// Load reads configuration from environment variables with defaults
|
||||
func Load() (*Config, error) {
|
||||
cfg := &Config{
|
||||
ListenAddr: getEnv("LISTEN_ADDR", ":8080"),
|
||||
BaseURL: getEnv("BASE_URL", "http://localhost:8080"),
|
||||
DatabasePath: getEnv("DATABASE_PATH", "./data/portal.db"),
|
||||
|
||||
JWTSecret: getEnv("JWT_SECRET", "change-me-in-production"),
|
||||
|
||||
GitHubClientID: os.Getenv("GITHUB_CLIENT_ID"),
|
||||
GitHubClientSecret: os.Getenv("GITHUB_CLIENT_SECRET"),
|
||||
|
||||
GoogleClientID: os.Getenv("GOOGLE_CLIENT_ID"),
|
||||
GoogleClientSecret: os.Getenv("GOOGLE_CLIENT_SECRET"),
|
||||
|
||||
PackagesDir: getEnv("PACKAGES_DIR", "./packages"),
|
||||
BackupsDir: getEnv("BACKUPS_DIR", "./backups"),
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func getEnv(key, defaultValue string) string {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
return value
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
Reference in New Issue
Block a user