
- Add database configuration with environment variable support - Support both PostgreSQL and SQLite database drivers - Implement connection pooling and timeout configuration - Add automatic database migration system - Include connection health checks and error handling - Configure SSL mode and connection parameters - Add utility functions for environment variable management
27 lines
665 B
Go
27 lines
665 B
Go
package config
|
|
|
|
import "git.secnex.io/secnex/certman/utils"
|
|
|
|
// Config holds database configuration
|
|
type Config struct {
|
|
Host string
|
|
Port string
|
|
User string
|
|
Password string
|
|
DBName string
|
|
SSLMode string
|
|
Driver string // "postgres" or "sqlite"
|
|
}
|
|
|
|
func GetConfig() *Config {
|
|
return &Config{
|
|
Host: utils.GetEnv("DB_HOST", "localhost"),
|
|
Port: utils.GetEnv("DB_PORT", "5432"),
|
|
User: utils.GetEnv("DB_USER", "postgres"),
|
|
Password: utils.GetEnv("DB_PASSWORD", "password"),
|
|
DBName: utils.GetEnv("DB_NAME", "certman"),
|
|
SSLMode: utils.GetEnv("DB_SSLMODE", "disable"),
|
|
Driver: utils.GetEnv("DB_DRIVER", "postgres"),
|
|
}
|
|
}
|