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

[V2] Clean up utils file #708

Merged
merged 2 commits into from
Oct 7, 2024
Merged

[V2] Clean up utils file #708

merged 2 commits into from
Oct 7, 2024

Conversation

rquitales
Copy link
Member

Proposed changes

This PR removes the custom min and max functions for the time.Duration type. Go v1.21 introduced built-in functions so we can rely on them. This PR also adds a simple test case for the existing exactlyOneOf function.

Go v1.21 adds built-in generic min and max functions. This removes the
need to maintain our own versions for the time.Duration types.
@rquitales rquitales added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Oct 4, 2024
@rquitales rquitales requested review from blampe and EronWright October 4, 2024 22:44
Copy link

codecov bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.37%. Comparing base (096b846) to head (d0d0956).
Report is 1 commits behind head on v2.

Additional details and impacted files
@@            Coverage Diff             @@
##               v2     #708      +/-   ##
==========================================
+ Coverage   49.23%   49.37%   +0.13%     
==========================================
  Files          26       26              
  Lines        2890     2882       -8     
==========================================
  Hits         1423     1423              
+ Misses       1290     1284       -6     
+ Partials      177      175       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@EronWright EronWright left a comment

Choose a reason for hiding this comment

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

Were the min/max functions not being used in the stack controller?

@rquitales
Copy link
Member Author

Were the min/max functions not being used in the stack controller?

min and max are used in the reconcile function to determine the requeue after time:

requeueAfter = max(1*time.Second, time.Until(instance.Status.LastUpdate.LastResyncTime.Add(resyncFreq)))
}
if stack.GitSource != nil {
trackBranch := len(stack.GitSource.Branch) > 0
if trackBranch {
// Reconcile every resyncFreq to check for new commits to the branch.
pollFreq := resyncFreq
log.Info("Commit hash unchanged. Will poll for new commits.", "pollFrequency", pollFreq)
requeueAfter = min(requeueAfter, pollFreq)

@rquitales rquitales merged commit 6fbcd4c into v2 Oct 7, 2024
7 checks passed
@rquitales rquitales deleted the rquitales/clean-up-utils branch October 7, 2024 17:15
@rquitales rquitales self-assigned this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants