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

Add IsPatch/Minor/Major/K0sUpgrade functions #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add IsPatch/Minor/Major/K0sUpgrade functions #21

wants to merge 1 commit into from

Conversation

kke
Copy link
Collaborator

@kke kke commented Jan 24, 2025

Adds functions for checking if upgrading to another version would be a patch, minor, major or k0s upgrade.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
@kke kke added the enhancement New feature or request label Jan 24, 2025
@kke kke marked this pull request as ready for review January 24, 2025 10:08
@kke kke requested a review from twz123 January 24, 2025 10:08
@@ -125,6 +125,14 @@ func (v *Version) Segments() []int {
return v.segments[:v.numSegments]
}

// segmentEqual checks if the segments at the specified index are equal between two versions.
func (v *Version) segmentEqual(b *Version, index int) bool {
if v == nil || b == nil || index < 0 || index >= maxSegments {
Copy link
Member

@twz123 twz123 Jan 24, 2025

Choose a reason for hiding this comment

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

Smart-ass question: If both v and b are nil, this function returns false, albeit v == b. This somehow breaks the transitive relationship that the method's name implies (i.e. I think it's reasonable to assume that a.segmentEqual(b) is true if a == b). Should we support the receiver being nil here in the first place? The existing methods don't do it, if I'm not mistaken.

Same for the other new methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants