refactor: unify database url configuration

Consolidate source/target connection handling around a single URL-based configuration model.
This commit is contained in:
2026-04-03 14:00:00 -05:00
parent d36b089916
commit f7b8dd73d4
2 changed files with 12 additions and 20 deletions

View File

@@ -7,13 +7,9 @@ import (
log "github.com/sirupsen/logrus"
)
type dbConfig struct {
Url string
}
type appConfig struct {
FromDb dbConfig
ToDb dbConfig
SourceDbUrl string
TargetDbUrl string
}
func loadEnv() {
@@ -26,23 +22,19 @@ func loadEnv() {
func getAppConfig() appConfig {
loadEnv()
fromDbUrl := os.Getenv("PG_FROM_DB_URL")
if fromDbUrl == "" {
log.Fatal("PG_FROM_DB_URL environment variable not set")
sourceDbUrl := os.Getenv("SOURCE_DB_URL")
if sourceDbUrl == "" {
log.Fatal("SOURCE_DB_URL environment variable not set")
}
toDbUrl := os.Getenv("PG_TO_DB_URL")
if toDbUrl == "" {
log.Fatal("PG_TO_DB_URL environment variable not set")
targetDbUrl := os.Getenv("TARGET_DB_URL")
if targetDbUrl == "" {
log.Fatal("TARGET_DB_URL environment variable not set")
}
return appConfig{
FromDb: dbConfig{
Url: fromDbUrl,
},
ToDb: dbConfig{
Url: toDbUrl,
},
SourceDbUrl: sourceDbUrl,
TargetDbUrl: targetDbUrl,
}
}