Skip to content
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

Merged
merged 3 commits into from
Apr 19, 2019
Merged

Conversation

tkyi
Copy link
Member

@tkyi tkyi commented Apr 19, 2019

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 a POST?

This PR also does some light refactoring, moving the updateAdmins function into events/index.js.

References

Related to #1285

@coveralls
Copy link

coveralls commented Apr 19, 2019

Coverage Status

Coverage increased (+0.008%) to 99.51% when pulling 0a11e24 on stopEvent into 8cfc8c6 on master.

Copy link
Contributor

@DekusDenial DekusDenial left a 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.

}

// PR author should be able to stop their own PR build
if (event.prNum && isPrOwner) {
Copy link
Member

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

permissions = userPermissions;

// Check if user has push access or is a Screwdriver admin
if (permissions.push || adminDetails.isAdmin) {
Copy link
Member

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

Copy link

@vnugopal vnugopal left a 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

@tkyi tkyi merged commit c9f3b4c into master Apr 19, 2019
@tkyi tkyi deleted the stopEvent branch April 19, 2019 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants