mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-15 04:57:56 +00:00
make golint happy
Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
This commit is contained in:
parent
894b7901ff
commit
1230945564
11 changed files with 24 additions and 19 deletions
|
@ -43,10 +43,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Namespace for feature labels
|
// LabelNs defines the Namespace for feature labels
|
||||||
LabelNs = "feature.node.kubernetes.io"
|
LabelNs = "feature.node.kubernetes.io"
|
||||||
|
|
||||||
// Base namespace for all NFD-related annotations
|
// AnnotationNsBase namespace for all NFD-related annotations
|
||||||
AnnotationNsBase = "nfd.node.kubernetes.io"
|
AnnotationNsBase = "nfd.node.kubernetes.io"
|
||||||
|
|
||||||
// NFD Annotations
|
// NFD Annotations
|
||||||
|
@ -65,7 +65,7 @@ type ExtendedResources map[string]string
|
||||||
// Annotations are used for NFD-related node metadata
|
// Annotations are used for NFD-related node metadata
|
||||||
type Annotations map[string]string
|
type Annotations map[string]string
|
||||||
|
|
||||||
// Command line arguments
|
// Args holds command line arguments
|
||||||
type Args struct {
|
type Args struct {
|
||||||
CaFile string
|
CaFile string
|
||||||
CertFile string
|
CertFile string
|
||||||
|
|
|
@ -51,13 +51,13 @@ func newDefaultConfig() *config {
|
||||||
return &config{}
|
return &config{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FeatureSource Interface
|
// Source implements FeatureSource Interface
|
||||||
type Source struct {
|
type Source struct {
|
||||||
config *config
|
config *config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return name of the feature source
|
// Name returns the name of the feature source
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return "custom" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Directory stores the full path for the custom sources folder
|
||||||
const Directory = "/etc/kubernetes/node-feature-discovery/custom.d"
|
const Directory = "/etc/kubernetes/node-feature-discovery/custom.d"
|
||||||
|
|
||||||
// getDirectoryFeatureConfig returns features configured in the "/etc/kubernetes/node-feature-discovery/custom.d"
|
// getDirectoryFeatureConfig returns features configured in the "/etc/kubernetes/node-feature-discovery/custom.d"
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rule that matches on loaded kernel modules in the system
|
// LoadedKModRule matches loaded kernel modules in the system
|
||||||
type LoadedKModRule []string
|
type LoadedKModRule []string
|
||||||
|
|
||||||
const kmodProcfsPath = "/proc/modules"
|
const kmodProcfsPath = "/proc/modules"
|
||||||
|
|
|
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -26,7 +27,7 @@ var (
|
||||||
nodeName = os.Getenv("NODE_NAME")
|
nodeName = os.Getenv("NODE_NAME")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rule that matches on nodenames configured in a ConfigMap
|
// NodenameRule matches on nodenames configured in a ConfigMap
|
||||||
type NodenameRule []string
|
type NodenameRule []string
|
||||||
|
|
||||||
// Force implementation of Rule
|
// Force implementation of Rule
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/klauspost/cpuid/v2"
|
"github.com/klauspost/cpuid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Discover returns feature names for all the supported CPU features.
|
// GetCpuidFlags returns feature names for all the supported CPU features.
|
||||||
func GetCpuidFlags() []string {
|
func GetCpuidFlags() []string {
|
||||||
return cpuid.CPU.FeatureSet()
|
return cpuid.CPU.FeatureSet()
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,12 +68,12 @@ func readPciDevInfo(devPath string, deviceAttrSpec map[string]bool) (PciDeviceIn
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// List available PCI devices and retrieve device attributes.
|
// DetectPci lists available PCI devices and retrieve device attributes.
|
||||||
// deviceAttrSpec is a map which specifies which attributes to retrieve.
|
// deviceAttrSpec is a map which specifies which attributes to retrieve.
|
||||||
// a false value for a specific attribute marks the attribute as optional.
|
// a false value for a specific attribute marks the attribute as optional.
|
||||||
// a true value for a specific attribute marks the attribute as mandatory.
|
// a true value for a specific attribute marks the attribute as mandatory.
|
||||||
// "class" attribute is considered mandatory.
|
// "class" attribute is considered mandatory.
|
||||||
// DetectPci() will fail if the retrieval of a mandatory attribute fails.
|
// will fail if the retrieval of a mandatory attribute fails.
|
||||||
func DetectPci(deviceAttrSpec map[string]bool) (map[string][]PciDeviceInfo, error) {
|
func DetectPci(deviceAttrSpec map[string]bool) (map[string][]PciDeviceInfo, error) {
|
||||||
sysfsBasePath := source.SysfsDir.Path("bus/pci/devices")
|
sysfsBasePath := source.SysfsDir.Path("bus/pci/devices")
|
||||||
devInfo := make(map[string][]PciDeviceInfo)
|
devInfo := make(map[string][]PciDeviceInfo)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
const Name = "iommu"
|
const Name = "iommu"
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Implement FeatureSource interface
|
||||||
|
// Source implements FeatureSource interface
|
||||||
type Source struct{}
|
type Source struct{}
|
||||||
|
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return Name }
|
||||||
|
|
|
@ -38,10 +38,11 @@ var (
|
||||||
hookDir = "/etc/kubernetes/node-feature-discovery/source.d/"
|
hookDir = "/etc/kubernetes/node-feature-discovery/source.d/"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Source implements FeatureSource interface
|
||||||
type Source struct{}
|
type Source struct{}
|
||||||
|
|
||||||
func (s Source) Name() string { return Name }
|
// Name returns the name of the feature source
|
||||||
|
func (s Source) Name() string { return "local" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return nil }
|
func (s *Source) NewConfig() source.Config { return nil }
|
||||||
|
@ -52,6 +53,7 @@ func (s *Source) GetConfig() source.Config { return nil }
|
||||||
// SetConfig method of the FeatureSource interface
|
// SetConfig method of the FeatureSource interface
|
||||||
func (s *Source) SetConfig(source.Config) {}
|
func (s *Source) SetConfig(source.Config) {}
|
||||||
|
|
||||||
|
// Discover returns features from hooks and files
|
||||||
func (s Source) Discover() (source.Features, error) {
|
func (s Source) Discover() (source.Features, error) {
|
||||||
featuresFromHooks, err := getFeaturesFromHooks()
|
featuresFromHooks, err := getFeaturesFromHooks()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -41,13 +41,13 @@ func newDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Source implements FeatureSource interface
|
||||||
type Source struct {
|
type Source struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return name of the feature source
|
// Name returns the name of the feature source
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return "pci" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
||||||
|
|
|
@ -44,13 +44,13 @@ func newDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Source implements FeatureSource interface
|
||||||
type Source struct {
|
type Source struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return name of the feature source
|
// Name returns the name of the feature source
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return "usb" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
||||||
|
|
Loading…
Add table
Reference in a new issue