-
Notifications
You must be signed in to change notification settings - Fork 169
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
feat(1285): Add endpoint for stopping all builds in an event #1592
Conversation
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.
LGTM overall. Recently I saw https://hapijs.com/api#-routeoptionspre and I do see a lot of user authz logic being repeated. Shamefully I did c&p one time and was meh 🤷♂️ . Hope it may seem refactorable to you at some point.
plugins/events/stopBuilds.js
Outdated
} | ||
|
||
// PR author should be able to stop their own PR build | ||
if (event.prNum && isPrOwner) { |
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.
we can combine || adminDetails.isAdmin
here and resolve
plugins/events/stopBuilds.js
Outdated
permissions = userPermissions; | ||
|
||
// Check if user has push access or is a Screwdriver admin | ||
if (permissions.push || adminDetails.isAdmin) { |
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 think we can remove this block updateAdmins
will do the adding/removing good/bad admins and resolves/throw
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.
pl ignore my approval. was trying some thing and added by mistake
Context
It can be annoying for users to have to manually stop each build in an event. It would be nice if they could stop all running/queued/blocked builds with one click or API call.
Objective
This PR adds an endpoint that checks/updates user permissions and gets all running/queued/blocked builds for an event and updates the status to
ABORTED
.Note: The endpoint is currently a
PUT /events/{id}/stop
, but open to any ideas.Wondering if
/events/{id}/builds/stop
or/events/{id}/builds/stopall
would be better. Or aPOST
?This PR also does some light refactoring, moving the
updateAdmins
function intoevents/index.js
.References
Related to #1285