Skip to content

Commit

Permalink
Don't fail on empty input (#10)
Browse files Browse the repository at this point in the history
It's better not to fail on empty input. This makes it easier for
scripted use cases to distinguish a "not found" case from a hard error
like invalid versions in the input.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 authored Jan 12, 2024
1 parent ca8d4f0 commit d6b8dd3
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cmd/k0s_sort/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,11 @@ func main() {

sort.Sort(versions)

if len(versions) == 0 {
println("no versions found")
os.Exit(1)
}

if latestFlag {
if latestFlag && len(versions) > 0 {
fmt.Printf("v%s\n", strings.TrimPrefix(versions[len(versions)-1].String(), "v"))
return
}

for _, v := range versions {
fmt.Printf("v%s\n", strings.TrimPrefix(v.String(), "v"))
}
Expand Down

0 comments on commit d6b8dd3

Please sign in to comment.