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

enhance(repo)!: add AllowSchedule field #291

Merged
merged 2 commits into from
May 19, 2023
Merged

Conversation

jbrockopp
Copy link
Contributor

@jbrockopp jbrockopp commented May 17, 2023

xref: go-vela/community#538

Part of go-vela/community#772

Based off of #289

This change add an AllowSchedule field to the Repo{} object:

AllowSchedule sql.NullBool `sql:"allow_schedule"`

AllowSchedule *bool `json:"allow_schedule,omitempty"`

Similar to the other Allow* fields, this will enable users to control if their repo responds to the schedule event.

Initially, I didn't plan to add this field since the Allow* fields control which git based events to respond to.

And schedules will be totally controlled by Vela (i.e. not SCM driven), and won't be an event for webhooks.

That being said, I wanted to start with opening this PR to collect feedback on if we should add this or not.

You can find an example of how this field will be used within go-vela/server#846.

NOTE: Marking this as a breaking change since it adds a new field which will require DB migrations.

@jbrockopp jbrockopp added the enhancement Indicates an improvement to a feature label May 17, 2023
@jbrockopp jbrockopp self-assigned this May 17, 2023
@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Merging #291 (eb7c705) into main (f538de0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #291   +/-   ##
=======================================
  Coverage   97.00%   97.01%           
=======================================
  Files          59       59           
  Lines        6545     6562   +17     
=======================================
+ Hits         6349     6366   +17     
  Misses        145      145           
  Partials       51       51           
Impacted Files Coverage Δ
database/repo.go 98.27% <100.00%> (+0.02%) ⬆️
library/repo.go 100.00% <100.00%> (ø)

@jbrockopp jbrockopp changed the title enhance(repo): add AllowSchedule field enhance(repo)!: add AllowSchedule field May 17, 2023
@jbrockopp jbrockopp marked this pull request as ready for review May 17, 2023 20:36
@jbrockopp jbrockopp requested a review from a team as a code owner May 17, 2023 20:36
Copy link
Contributor

@plyr4 plyr4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, seems like a straightforward way to disable repo schedules without actually removing the schedule or disabling event-driven builds. nice

Copy link
Collaborator

@wass3r wass3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me, but i can see your hesitation about adding non-SCM events here. i think it's fine.

@jbrockopp
Copy link
Contributor Author

@ecrupper @plyr4 @wass3r only one last caveat to point out and then I think we can merge 👍

The server scan's the entire schedules table for all schedules with active == true.

This would include any schedules for a repo that have the schedule event disabled.

This could mean the server spends unneeded extra cycles processing schedules for a repo with that event disabled.

We could perform a JOIN with the repos table to check for the event being disabled?

However, in general, I try to avoid JOIN queries since they can be taxing on the system especially for large tables.

@cognifloyd
Copy link
Member

I think the per repo flag complicates things. It might be a good idea, but the global allow list is sufficient for now, so let's wait till after the rest of schedules are implemented and then work on adding the per-repo flag.

@wass3rw3rk
Copy link
Member

@jbrockopp thanks for calling attention to that. i'm good with the approach @cognifloyd mentioned.

@wass3rw3rk wass3rw3rk merged commit 71117bf into main May 19, 2023
@wass3rw3rk wass3rw3rk deleted the enhance/repo/allow_schedule branch May 19, 2023 16:47
@jbrockopp
Copy link
Contributor Author

jbrockopp commented May 19, 2023

@wass3rw3rk perhaps I misunderstood, but if we want to go with that approach we shouldn't merge this, right?

So I think we'll need to revert this PR and then I can open a new one with this change as a draft PR.

Otherwise, we'll be unable to pull this repo (as a go dependency) on the main branch into go-vela/server.

jbrockopp added a commit that referenced this pull request May 19, 2023
ecrupper pushed a commit that referenced this pull request May 19, 2023
* Revert "enhance(repo): add AllowSchedule field (#291)"

This reverts commit 71117bf.

* chore: keep copyright year change
@jbrockopp jbrockopp restored the enhance/repo/allow_schedule branch May 22, 2023 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates an improvement to a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants