chore: consolidate DBURL into DATA_DIR, codebase audit for 1.0.0
All checks were successful
check / check (push) Successful in 56s
All checks were successful
check / check (push) Successful in 56s
DBURL → DATA_DIR consolidation:
- Remove DBURL env var entirely; main DB now lives at {DATA_DIR}/webhooker.db
- database.go constructs DB path from config.DataDir, ensures dir exists
- Update DATA_DIR prod default from /data/events to /data
- Update all tests to use DataDir instead of DBURL
- Update Dockerfile: /data (not /data/events) for all SQLite databases
- Update README configuration table, Docker examples, architecture docs
Dead code removal:
- Remove unused IndexResponse struct (handlers/index.go)
- Remove unused TemplateData struct (handlers/handlers.go)
Stale comment cleanup:
- Remove TODO in server.go (DB cleanup handled by fx lifecycle)
- Fix nolint:golint → nolint:revive on ServerParams for consistency
- Clean up verbose middleware/routing comments in routes.go
- Fix TODO fan-out description (worker pool, not goroutine-per-target)
.gitignore fixes:
- Add data/ directory to gitignore
- Remove stale config.yaml entry (env-only config since rework)
This commit is contained in:
@@ -31,7 +31,6 @@ type ConfigParams struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
DBURL string
|
||||
DataDir string
|
||||
Debug bool
|
||||
MaintenanceMode bool
|
||||
@@ -99,7 +98,6 @@ func New(lc fx.Lifecycle, params ConfigParams) (*Config, error) {
|
||||
|
||||
// Load configuration values from environment variables
|
||||
s := &Config{
|
||||
DBURL: envString("DBURL"),
|
||||
DataDir: envString("DATA_DIR"),
|
||||
Debug: envBool("DEBUG", false),
|
||||
MaintenanceMode: envBool("MAINTENANCE_MODE", false),
|
||||
@@ -113,20 +111,16 @@ func New(lc fx.Lifecycle, params ConfigParams) (*Config, error) {
|
||||
params: ¶ms,
|
||||
}
|
||||
|
||||
// Set default DataDir based on environment
|
||||
// Set default DataDir based on environment. All SQLite databases
|
||||
// (main application DB and per-webhook event DBs) live here.
|
||||
if s.DataDir == "" {
|
||||
if s.IsProd() {
|
||||
s.DataDir = "/data/events"
|
||||
s.DataDir = "/data"
|
||||
} else {
|
||||
s.DataDir = "./data"
|
||||
}
|
||||
}
|
||||
|
||||
// Validate database URL
|
||||
if s.DBURL == "" {
|
||||
return nil, fmt.Errorf("database URL (DBURL) is required")
|
||||
}
|
||||
|
||||
if s.Debug {
|
||||
params.Logger.EnableDebugLogging()
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestEnvironmentConfig(t *testing.T) {
|
||||
{
|
||||
name: "default is dev",
|
||||
envValue: "",
|
||||
envVars: map[string]string{"DBURL": "file::memory:?cache=shared"},
|
||||
envVars: map[string]string{},
|
||||
expectError: false,
|
||||
isDev: true,
|
||||
isProd: false,
|
||||
@@ -32,17 +32,15 @@ func TestEnvironmentConfig(t *testing.T) {
|
||||
{
|
||||
name: "explicit dev",
|
||||
envValue: "dev",
|
||||
envVars: map[string]string{"DBURL": "file::memory:?cache=shared"},
|
||||
envVars: map[string]string{},
|
||||
expectError: false,
|
||||
isDev: true,
|
||||
isProd: false,
|
||||
},
|
||||
{
|
||||
name: "explicit prod",
|
||||
envValue: "prod",
|
||||
envVars: map[string]string{
|
||||
"DBURL": "postgres://prod:prod@localhost:5432/prod?sslmode=require",
|
||||
},
|
||||
name: "explicit prod",
|
||||
envValue: "prod",
|
||||
envVars: map[string]string{},
|
||||
expectError: false,
|
||||
isDev: false,
|
||||
isProd: true,
|
||||
@@ -50,7 +48,7 @@ func TestEnvironmentConfig(t *testing.T) {
|
||||
{
|
||||
name: "invalid environment",
|
||||
envValue: "staging",
|
||||
envVars: map[string]string{"DBURL": "file::memory:?cache=shared"},
|
||||
envVars: map[string]string{},
|
||||
expectError: true,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user