mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-29 00:01:22 +00:00
Consolidate backend: drop vendored APwhy, converge on goose + sqlc
Phase 0 cleanup verified end-to-end:
- Delete vendored APwhy runtime (cmd/apwhy, internal/apwhy) and the
unwired copy (internal/api/server.go + static bundle + cloned
internal/{storage,analytics,auth,rbac}) — ~7.5k lines of dead code.
- Keep Containr's native internal/gateway; move APwhy management
routes under /api/v1/gateway/* so they stop colliding with the
native /services paths. Fix handlers against the real schema:
UUID ids via RETURNING, integer enabled flags, plan validation,
service validate endpoint, unique-violation mapping.
- Port agents.go off GORM onto sqlc (sqlc/queries/agents.sql);
drop gorm dependencies; fix sqlc schema drift (services.environment_id).
- Replace the SELECT 1 goose baseline with the real consolidated
schema (52 tables) minus APwhy's parallel auth/RBAC objects;
idempotent via IF NOT EXISTS / OR REPLACE / guarded DO blocks so it
replays cleanly over legacy installs. Add a drop migration for the
dead objects and delete the legacy filename-tracked migrations/
loader, directory, and Dockerfile copy. Verified via cmd/migrate:
fresh install 53 tables, legacy upgrade clean to 20260917000000.
- Canvas: add invisible React Flow handles to ServiceNode so inferred
auto-connections stop emitting warning #008.
- Remove reactflow dep (superseded by @xyflow/react), test harness
cmds, and legacy 0001_init.sql backups.
Authored By: TDvorak <[email protected]>
This commit is contained in:
1 parent
37a56dc6b6
commit
9e3aa3aa17
153 files changed
+6996
-11135
No files matched your search
@@ -17,8 +17,6 @@ import (
|
||||
"containr/internal/scaling"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func SetupRoutes(router *gin.Engine, db *database.DB, redis *database.Redis, cfg *config.Config) {
|
||||
@@ -56,14 +54,8 @@ func SetupRoutes(router *gin.Engine, db *database.DB, redis *database.Redis, cfg
|
||||
// Initialize scaling handler
|
||||
scalingHandler := NewScalingHandler(autoScaler)
|
||||
|
||||
// Initialize GORM for agent system
|
||||
gormDB, err := gorm.Open(postgres.Open(cfg.DatabaseURL), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic("Failed to initialize GORM: " + err.Error())
|
||||
}
|
||||
|
||||
// Initialize agent handler
|
||||
agentHandler := NewNodeAgentHandler(gormDB)
|
||||
// Initialize agent handler (sqlc-backed)
|
||||
agentHandler := NewNodeAgentHandler(db)
|
||||
|
||||
// Initialize database handler
|
||||
databaseHandler := NewDatabaseHandler(db.DB, dockerClient)
|
||||
@@ -90,7 +82,6 @@ func SetupRoutes(router *gin.Engine, db *database.DB, redis *database.Redis, cfg
|
||||
c.Set("auto_scaler", autoScaler)
|
||||
c.Set("ha_manager", haManager)
|
||||
c.Set("scaling_handler", scalingHandler)
|
||||
c.Set("gorm_db", gormDB)
|
||||
c.Next()
|
||||
})
|
||||
|
||||
@@ -298,42 +289,23 @@ func SetupRoutes(router *gin.Engine, db *database.DB, redis *database.Redis, cfg
|
||||
// Audit Logs routes
|
||||
protected.GET("/audit-logs", handleGetAuditLogs)
|
||||
protected.GET("/audit-logs/:resource/:id", handleGetResourceAuditLogs)
|
||||
}
|
||||
|
||||
// APwhy Gateway routes
|
||||
apwhy := router.Group("/api/v1")
|
||||
{
|
||||
// Health check (no auth required)
|
||||
apwhy.GET("/health", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"ok": true,
|
||||
"data": gin.H{
|
||||
"status": "ok",
|
||||
"name": "Containr + APwhy",
|
||||
"database": "postgresql",
|
||||
"generatedAt": time.Now().UTC().Format(time.RFC3339),
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
// API Gateway routes (merged APwhy) - namespaced to avoid
|
||||
// colliding with Containr's own /services paths.
|
||||
gateway := protected.Group("/gateway")
|
||||
{
|
||||
gateway.GET("/services", handleAPwhyServicesList)
|
||||
gateway.POST("/services", handleAPwhyServicesCreate)
|
||||
gateway.PATCH("/services/:id", handleAPwhyServicesPatch)
|
||||
gateway.GET("/services/:id/validate", handleAPwhyServiceValidate)
|
||||
|
||||
// Protected APwhy routes (authentication required)
|
||||
protectedAPwhy := router.Group("/api/v1")
|
||||
protectedAPwhy.Use(middleware.Auth(cfg.JWTSecret))
|
||||
{
|
||||
// Service management
|
||||
protectedAPwhy.GET("/services", handleAPwhyServicesList)
|
||||
protectedAPwhy.POST("/services", handleAPwhyServicesCreate)
|
||||
protectedAPwhy.PATCH("/services/:id", handleAPwhyServicesPatch)
|
||||
gateway.GET("/keys", handleAPwhyKeysList)
|
||||
gateway.POST("/keys", handleAPwhyKeysCreate)
|
||||
gateway.PATCH("/keys/:id", handleAPwhyKeysPatch)
|
||||
|
||||
// API Keys
|
||||
protectedAPwhy.GET("/keys", handleAPwhyKeysList)
|
||||
protectedAPwhy.POST("/keys", handleAPwhyKeysCreate)
|
||||
protectedAPwhy.PATCH("/keys/:id", handleAPwhyKeysPatch)
|
||||
|
||||
// Analytics
|
||||
protectedAPwhy.GET("/analytics/ops", handleAPwhyAnalyticsOps)
|
||||
protectedAPwhy.GET("/analytics/traffic", handleAPwhyAnalyticsTraffic)
|
||||
gateway.GET("/analytics/ops", handleAPwhyAnalyticsOps)
|
||||
gateway.GET("/analytics/traffic", handleAPwhyAnalyticsTraffic)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user