Sort drivers for nvproxy list-supported-drivers command.

Sort drivers for runsc command so that it is easier to find if a driver
is supported or not.

PiperOrigin-RevId: 659610598
This commit is contained in:
Zach Koopmans
2024-08-05 11:04:38 -07:00
committed by gVisor bot
parent 2ef09d3bdd
commit 5e00026dc9
2 changed files with 17 additions and 3 deletions
+14
View File
@@ -17,6 +17,7 @@ package nvproxy
import (
"fmt"
"reflect"
"sort"
"strconv"
"strings"
@@ -722,6 +723,19 @@ func LatestDriver() DriverVersion {
return ret
}
// SupportedDrivers returns a list of all supported drivers.
// Precondition: Init() must have been called.
func SupportedDrivers() []DriverVersion {
var ret []DriverVersion
for version := range abis {
ret = append(ret, version)
}
sort.Slice(ret, func(i, j int) bool {
return !ret[i].isGreaterThan(ret[j])
})
return ret
}
// ExpectedDriverChecksum returns the expected checksum for a given version.
// Precondition: Init() must have been called.
func ExpectedDriverChecksum(version DriverVersion) (string, bool) {
+3 -3
View File
@@ -53,9 +53,9 @@ func (*listSupportedDrivers) Execute(ctx context.Context, f *flag.FlagSet, args
return subcommands.ExitUsageError
}
nvproxy.ForEachSupportDriver(func(version nvproxy.DriverVersion, _ string) {
fmt.Println(version)
})
for _, d := range nvproxy.SupportedDrivers() {
fmt.Println(d)
}
return subcommands.ExitSuccess
}