-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
See "A motivating example" in issue #290.
It should be possible to make it so that none of the handlers in build.go reference a gorm DB directly, only through a buildRepo.
For example:
platform/handlers/api/build.go
Lines 128 to 144 in ffb20d4
| // Report fetches a build's report. | |
| func (b Build) Report(c *gin.Context) { | |
| buildRepo := models.BuildDataSource(db) | |
| build, err := b.ByID(c) | |
| if err != nil { | |
| return | |
| } | |
| report, err := buildRepo.GetBuildReport(build) | |
| if err != nil { | |
| sugar.NotFoundOrError(c, err) | |
| return | |
| } | |
| sugar.SuccessResponse(c, 200, report) | |
| } |
Line 130 should be moved out to the main entry point, and b.ByID(c) should be broken up into
- a thing which figures out the
BuildIDfor the request, and - a
buildRepo.ByID(id)call which returns the build ID.
This issue is fixed when handlers/api/build.go no longer refers to the db global variable.
Metadata
Metadata
Assignees
Labels
No labels