-
Notifications
You must be signed in to change notification settings - Fork 30
refactor(database): move build logic into separate package #858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #858 +/- ##
==========================================
- Coverage 66.79% 66.12% -0.68%
==========================================
Files 283 297 +14
Lines 14144 13879 -265
==========================================
- Hits 9448 9177 -271
- Misses 4249 4255 +6
Partials 447 447
|
|
|
||
| for _, deployment := range d { | ||
| b, err := database.FromContext(c).GetDeploymentBuildList(*deployment.URL) | ||
| b, _, err := database.FromContext(c).ListBuildsForDeployment(deployment, nil, 1, 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about this line here. Is there a maximum number of three builds that can result from a deployment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My memory is a little fuzzy on the exact details but I believe 3 was chosen as a starting point? 😅
IIRC, we don't have anything that limits the amount of builds that can be tied to a specific deployment 👍
The reason why I'm using 3 here is because that's how the code was originally implemented:
FWIW - I have no objections to increasing this to 10 since that's more consistent with our default per_page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting... didn't catch that. Yeah I don't really care tbh, 3 works.
Based off of #574, #663, #687, #692, #721, #722, #782, #810 and #816
This change continues the refactor efforts initially introduced in the above PRs.
This adds a new
buildpackage to thegithub.amrom.workers.dev/go-vela/server/databasepackage.This contains a
BuildInterfaceinterface declaring all functions necessary for build based interactions with the database:server/database/build/interface.go
Lines 11 to 61 in efada99
This package also contains the
enginewhich implements the above build interface:server/database/build/build.go
Lines 23 to 37 in efada99
This
enginecontains no raw SQL queries for integrating with thebuildstable.Instead, we leverage our DB library's (https://gorm.io/) agnostic abstraction for integrating with that table.