1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-15 04:57:56 +00:00

source/usb: fix fallback to default label format

This commit is contained in:
Markus Lehtonen 2021-12-09 18:26:08 +02:00
parent afe07d6e19
commit 19e0f77cb5

View file

@ -43,10 +43,12 @@ func newDefaultConfig() *Config {
// By default these include classes where different accelerators are typically mapped: // By default these include classes where different accelerators are typically mapped:
// Video (0e), Miscellaneous (ef), Application Specific (fe), and Vendor Specific (ff). // Video (0e), Miscellaneous (ef), Application Specific (fe), and Vendor Specific (ff).
DeviceClassWhitelist: []string{"0e", "ef", "fe", "ff"}, DeviceClassWhitelist: []string{"0e", "ef", "fe", "ff"},
DeviceLabelFields: []string{"class", "vendor", "device"}, DeviceLabelFields: defaultDeviceLabelFields(),
} }
} }
func defaultDeviceLabelFields() []string { return []string{"class", "vendor", "device"} }
// usbSource implements the LabelSource and ConfigurableSource interfaces. // usbSource implements the LabelSource and ConfigurableSource interfaces.
type usbSource struct { type usbSource struct {
config *Config config *Config
@ -110,7 +112,7 @@ func (s *usbSource) GetLabels() (source.FeatureLabels, error) {
} }
if len(deviceLabelFields) == 0 { if len(deviceLabelFields) == 0 {
klog.Warningf("no valid fields in deviceLabelFields defined, using the defaults") klog.Warningf("no valid fields in deviceLabelFields defined, using the defaults")
deviceLabelFields = []string{"vendor", "device"} deviceLabelFields = defaultDeviceLabelFields()
} }
// Iterate over all device classes // Iterate over all device classes