mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
refactor(db): port deployments to sqlc (#78)
Tranche 4: all 32 raw sites in deployments.go — paginated service list, the accessible-feed joins (owner/member/admin/approved), service+owner load, deployment insert, status transitions (fail/complete/set), the 10-field progress sync, cancel access check, rollback reads/inserts, and the published_port reuse read. The shared serviceForDeployFromRow mapper now feeds both the preview and deployments loaders. Live test covers the full lifecycle: insert, list, access join, feed predicate, queued → deployed sync, failed transition. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
202fdd7b5a
commit
cca20f7eae
6 files changed
+1043
-285
No files matched your search
@@ -775,11 +775,7 @@ func resolvePreviewHost(db *database.DB, cloneID uuid.UUID, envName string) stri
|
||||
|
||||
// loadServiceForDeploy hydrates the Service fields runDeploymentAndSync
|
||||
// needs — mirrors the loader in handleDeployService.
|
||||
func loadServiceForDeploy(db *database.DB, serviceID uuid.UUID) (Service, error) {
|
||||
r, err := sqlcdb.New(db.DB).GetServiceForDeploy(context.Background(), serviceID)
|
||||
if err != nil {
|
||||
return Service{}, err
|
||||
}
|
||||
func serviceForDeployFromRow(r sqlcdb.GetServiceForDeployRow) Service {
|
||||
return Service{
|
||||
ID: r.ID, ProjectID: r.ProjectID, Name: r.Name, Type: r.Type.String,
|
||||
Status: r.Status.String, Image: r.Image.String, Command: r.Command.String,
|
||||
@@ -791,7 +787,15 @@ func loadServiceForDeploy(db *database.DB, serviceID uuid.UUID) (Service, error)
|
||||
Builder: r.Builder, CPUReserve: r.CpuReserve, MemoryReserve: r.MemoryReserve,
|
||||
StaticBuildCmd: r.StaticBuildCmd, StaticDir: r.StaticDir,
|
||||
CreatedAt: r.CreatedAt.Time, UpdatedAt: r.UpdatedAt.Time,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func loadServiceForDeploy(db *database.DB, serviceID uuid.UUID) (Service, error) {
|
||||
r, err := sqlcdb.New(db.DB).GetServiceForDeploy(context.Background(), serviceID)
|
||||
if err != nil {
|
||||
return Service{}, err
|
||||
}
|
||||
return serviceForDeployFromRow(r), nil
|
||||
}
|
||||
|
||||
// StartPreviewSweeper expires preview environments past their TTL — tears
|
||||
|
||||
Reference in new issue
Block a user