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

Allow underscores in versions #32

Merged
merged 1 commit into from
Feb 20, 2024
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: 9 additions & 2 deletions pkg/drvinfo/drvinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package drvinfo
import (
"log"
"os"
"strings"

"github.com/hashicorp/go-version"
"github.com/safchain/ethtool"
Expand Down Expand Up @@ -69,11 +70,17 @@ func (dl *SupportedDrivers) IsDriverSupported(drv *DriverInfo) bool {
if d.Name != drv.Name {
continue
}
supported, err := version.NewVersion(d.Version)

// Remove underscores to keep goversion happy
// See: https://github.com/k8snetworkplumbingwg/sriov-network-metrics-exporter/issues/31
dVersionSanitized := strings.ReplaceAll(d.Version, "_", "")
drvVersionSanitized := strings.ReplaceAll(drv.Version, "_", "")

supported, err := version.NewVersion(dVersionSanitized)
if err != nil {
continue
}
v, err := version.NewVersion(drv.Version)
v, err := version.NewVersion(drvVersionSanitized)
if err != nil {
continue
}
Expand Down
1 change: 1 addition & 0 deletions pkg/drvinfo/drvinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ var _ = Describe("drvinfo", func() {
Entry("return true if driver is supported", getTestDrv(), true, NewSupportedDrivers(getDbFilePath())),
Entry("return false if driver is not supported", &DriverInfo{Name: "ice", Version: "1.8.1"}, false, NewSupportedDrivers(getDbFilePath())),
Entry("return true if driver version is greater than supported", &DriverInfo{Name: "ice", Version: "1.10.1"}, true, NewSupportedDrivers(getDbFilePath())),
Entry("return true if driver version is greater than supported and includes underscore", &DriverInfo{Name: "ice", Version: "1.10.1-x86_64"}, true, NewSupportedDrivers(getDbFilePath())),
)

DescribeTable("readSupportedDrivers should", func(testDrv *DriverInfo) {
Expand Down
Loading