diff --git a/source/cpu/cpu.go b/source/cpu/cpu.go index 22680d815..9802e3fc8 100644 --- a/source/cpu/cpu.go +++ b/source/cpu/cpu.go @@ -25,6 +25,8 @@ import ( "sigs.k8s.io/node-feature-discovery/source/internal/cpuidutils" ) +const Name = "cpu" + // Configuration file options type cpuidConfig struct { AttributeBlacklist []string `json:"attributeBlacklist,omitempty"` @@ -82,7 +84,7 @@ type Source struct { cpuidFilter *keyFilter } -func (s Source) Name() string { return "cpu" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return newDefaultConfig() } diff --git a/source/custom/custom.go b/source/custom/custom.go index d99dff36b..9100f56b1 100644 --- a/source/custom/custom.go +++ b/source/custom/custom.go @@ -26,6 +26,8 @@ import ( "sigs.k8s.io/node-feature-discovery/source/custom/rules" ) +const Name = "custom" + // Custom Features Configurations type MatchRule struct { PciID *rules.PciIDRule `json:"pciId,omitempty"` @@ -55,7 +57,7 @@ type Source struct { } // Return name of the feature source -func (s Source) Name() string { return "custom" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return newDefaultConfig() } diff --git a/source/fake/fake.go b/source/fake/fake.go index 4b9d56c8b..0a90277db 100644 --- a/source/fake/fake.go +++ b/source/fake/fake.go @@ -22,6 +22,8 @@ import ( "sigs.k8s.io/node-feature-discovery/source" ) +const Name = "fake" + // Configuration file options type Config struct { Labels map[string]string `json:"labels"` @@ -44,7 +46,7 @@ type Source struct { } // Name returns an identifier string for this feature source. -func (s Source) Name() string { return "fake" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return newDefaultConfig() } diff --git a/source/iommu/iommu.go b/source/iommu/iommu.go index ae9f78b7e..20558d815 100644 --- a/source/iommu/iommu.go +++ b/source/iommu/iommu.go @@ -23,10 +23,12 @@ import ( "sigs.k8s.io/node-feature-discovery/source" ) +const Name = "iommu" + // Implement FeatureSource interface type Source struct{} -func (s Source) Name() string { return "iommu" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return nil } diff --git a/source/kernel/kernel.go b/source/kernel/kernel.go index 16f1f73cb..d7fc2f4d4 100644 --- a/source/kernel/kernel.go +++ b/source/kernel/kernel.go @@ -26,6 +26,8 @@ import ( "sigs.k8s.io/node-feature-discovery/source/internal/kernelutils" ) +const Name = "kernel" + // Configuration file options type Config struct { KconfigFile string @@ -50,7 +52,7 @@ type Source struct { config *Config } -func (s *Source) Name() string { return "kernel" } +func (s *Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return newDefaultConfig() } diff --git a/source/local/local.go b/source/local/local.go index 3d1dee1fb..d7d3dbdb9 100644 --- a/source/local/local.go +++ b/source/local/local.go @@ -30,6 +30,8 @@ import ( "sigs.k8s.io/node-feature-discovery/source" ) +const Name = "local" + // Config var ( featureFilesDir = "/etc/kubernetes/node-feature-discovery/features.d/" @@ -39,7 +41,7 @@ var ( // Implement FeatureSource interface type Source struct{} -func (s Source) Name() string { return "local" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return nil } diff --git a/source/memory/memory.go b/source/memory/memory.go index 87bac0952..8669303d3 100644 --- a/source/memory/memory.go +++ b/source/memory/memory.go @@ -26,11 +26,13 @@ import ( "sigs.k8s.io/node-feature-discovery/source" ) +const Name = "memory" + // Source implements FeatureSource. type Source struct{} // Name returns an identifier string for this feature source. -func (s Source) Name() string { return "memory" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return nil } diff --git a/source/network/network.go b/source/network/network.go index 25cd1a009..56c767d01 100644 --- a/source/network/network.go +++ b/source/network/network.go @@ -28,6 +28,8 @@ import ( "sigs.k8s.io/node-feature-discovery/source" ) +const Name = "network" + // Linux net iface flags (we only specify the first few) const ( flagUp = 1 << iota @@ -42,7 +44,7 @@ const sysfsBaseDir = "class/net" type Source struct{} // Name returns an identifier string for this feature source. -func (s Source) Name() string { return "network" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return nil } diff --git a/source/pci/pci.go b/source/pci/pci.go index 12a5ea6d9..9e6f6ecca 100644 --- a/source/pci/pci.go +++ b/source/pci/pci.go @@ -26,6 +26,8 @@ import ( pciutils "sigs.k8s.io/node-feature-discovery/source/internal" ) +const Name = "pci" + type Config struct { DeviceClassWhitelist []string `json:"deviceClassWhitelist,omitempty"` DeviceLabelFields []string `json:"deviceLabelFields,omitempty"` @@ -45,7 +47,7 @@ type Source struct { } // Return name of the feature source -func (s Source) Name() string { return "pci" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return newDefaultConfig() } diff --git a/source/storage/storage.go b/source/storage/storage.go index 632a2ee3b..f0c5dec5f 100644 --- a/source/storage/storage.go +++ b/source/storage/storage.go @@ -23,11 +23,13 @@ import ( "sigs.k8s.io/node-feature-discovery/source" ) +const Name = "storage" + // Source implements FeatureSource. type Source struct{} // Name returns an identifier string for this feature source. -func (s Source) Name() string { return "storage" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return nil } diff --git a/source/system/system.go b/source/system/system.go index 1633dc1cf..59b397036 100644 --- a/source/system/system.go +++ b/source/system/system.go @@ -32,10 +32,12 @@ var osReleaseFields = [...]string{ "VERSION_ID", } +const Name = "system" + // Implement FeatureSource interface type Source struct{} -func (s Source) Name() string { return "system" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return nil } diff --git a/source/usb/usb.go b/source/usb/usb.go index bf082ef0b..bb5f917fa 100644 --- a/source/usb/usb.go +++ b/source/usb/usb.go @@ -26,6 +26,8 @@ import ( usbutils "sigs.k8s.io/node-feature-discovery/source/internal" ) +const Name = "usb" + type Config struct { DeviceClassWhitelist []string `json:"deviceClassWhitelist,omitempty"` DeviceLabelFields []string `json:"deviceLabelFields,omitempty"` @@ -48,7 +50,7 @@ type Source struct { } // Return name of the feature source -func (s Source) Name() string { return "usb" } +func (s Source) Name() string { return Name } // NewConfig method of the FeatureSource interface func (s *Source) NewConfig() source.Config { return newDefaultConfig() }