Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/go/rpk/pkg/redpanda/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ func (v Version) Less(b Version) bool {

// IsAtLeast returns true if the version is greater than or equal to the passed version.
func (v Version) IsAtLeast(b Version) bool {
if v.Major >= b.Major {
if v.Feature >= b.Feature {
return v.Patch >= b.Patch
}
if v.Major != b.Major {
return v.Major > b.Major
}
if v.Feature != b.Feature {
return v.Feature > b.Feature
}
return false
return v.Patch >= b.Patch
}

func (v Version) String() string {
Expand Down
1 change: 1 addition & 0 deletions src/go/rpk/pkg/redpanda/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestVersion_IsAtLeast(t *testing.T) {
{"lower year", Version{23, 1, 1}, Version{22, 1, 1}, true},
{"lower feature", Version{22, 3, 23}, Version{22, 2, 23}, true},
{"lower patch", Version{23, 4, 23}, Version{23, 4, 22}, true},
{"next major with lower minor and patch", Version{26, 1, 1}, Version{25, 3, 2}, true},
} {
t.Run(test.name, func(t *testing.T) {
require.Equal(t, test.a.IsAtLeast(test.b), test.exp)
Expand Down
Loading