Skip to content

Commit

Permalink
reconsider k8s version comparision
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhasmitaSw committed Mar 7, 2022
1 parent 0195739 commit 6123e0d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions util/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,23 @@ func WithBuildTags() CompareOption {
}
}

func WithoutPreReleases() CompareOption {
return func(c *comparer) {
c.withoutPreReleases = true
}
}

// Compare 2 semver versions.
// Defaults to doing the standard semver comparison when no options are specified.
// The comparison logic can be modified by passing additional compare options.
// Example: using the WithBuildTags() option modifies the compare logic to also
// consider build tags when comparing versions.
func Compare(a, b semver.Version, options ...CompareOption) int {
if c. withoutPreReleases {
a.Pre = nil
b.Pre = nil
}

c := &comparer{}
for _, o := range options {
o(c)
Expand Down

0 comments on commit 6123e0d

Please sign in to comment.