mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
Add 'custom' feature Source to nfd-worker
This commit is contained in:
parent
e4e3a9f68e
commit
192b3d7bdd
3 changed files with 9 additions and 3 deletions
|
@ -91,7 +91,7 @@ func argsParse(argv []string) (worker.Args, error) {
|
|||
in testing
|
||||
[Default: ]
|
||||
--sources=<sources> Comma separated list of feature sources.
|
||||
[Default: cpu,iommu,kernel,local,memory,network,pci,storage,system]
|
||||
[Default: cpu,custom,iommu,kernel,local,memory,network,pci,storage,system]
|
||||
--no-publish Do not publish discovered features to the
|
||||
cluster-local Kubernetes API server.
|
||||
--label-whitelist=<pattern> Regular expression to filter label names to
|
||||
|
|
|
@ -23,6 +23,8 @@ import (
|
|||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
var allSources = []string{"cpu", "custom", "iommu", "kernel", "local", "memory", "network", "pci", "storage", "system"}
|
||||
|
||||
func TestArgsParse(t *testing.T) {
|
||||
Convey("When parsing command line arguments", t, func() {
|
||||
Convey("When --no-publish and --oneshot flags are passed", func() {
|
||||
|
@ -32,7 +34,7 @@ func TestArgsParse(t *testing.T) {
|
|||
So(args.SleepInterval, ShouldEqual, 60*time.Second)
|
||||
So(args.NoPublish, ShouldBeTrue)
|
||||
So(args.Oneshot, ShouldBeTrue)
|
||||
So(args.Sources, ShouldResemble, []string{"cpu", "iommu", "kernel", "local", "memory", "network", "pci", "storage", "system"})
|
||||
So(args.Sources, ShouldResemble, allSources)
|
||||
So(len(args.LabelWhiteList), ShouldEqual, 0)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
@ -56,7 +58,7 @@ func TestArgsParse(t *testing.T) {
|
|||
|
||||
Convey("args.labelWhiteList is set to appropriate value and args.sources is set to default value", func() {
|
||||
So(args.NoPublish, ShouldBeFalse)
|
||||
So(args.Sources, ShouldResemble, []string{"cpu", "iommu", "kernel", "local", "memory", "network", "pci", "storage", "system"})
|
||||
So(args.Sources, ShouldResemble, allSources)
|
||||
So(args.LabelWhiteList, ShouldResemble, ".*rdt.*")
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
|
|
@ -36,6 +36,7 @@ import (
|
|||
"sigs.k8s.io/node-feature-discovery/pkg/version"
|
||||
"sigs.k8s.io/node-feature-discovery/source"
|
||||
"sigs.k8s.io/node-feature-discovery/source/cpu"
|
||||
"sigs.k8s.io/node-feature-discovery/source/custom"
|
||||
"sigs.k8s.io/node-feature-discovery/source/fake"
|
||||
"sigs.k8s.io/node-feature-discovery/source/iommu"
|
||||
"sigs.k8s.io/node-feature-discovery/source/kernel"
|
||||
|
@ -61,6 +62,7 @@ type NFDConfig struct {
|
|||
Cpu *cpu.NFDConfig `json:"cpu,omitempty"`
|
||||
Kernel *kernel.NFDConfig `json:"kernel,omitempty"`
|
||||
Pci *pci.NFDConfig `json:"pci,omitempty"`
|
||||
Custom *custom.NFDConfig `json:"custom,omitempty"`
|
||||
} `json:"sources,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -234,6 +236,7 @@ func configParse(filepath string, overrides string) error {
|
|||
config.Sources.Cpu = &cpu.Config
|
||||
config.Sources.Kernel = &kernel.Config
|
||||
config.Sources.Pci = &pci.Config
|
||||
config.Sources.Custom = &custom.Config
|
||||
|
||||
data, err := ioutil.ReadFile(filepath)
|
||||
if err != nil {
|
||||
|
@ -276,6 +279,7 @@ func configureParameters(sourcesWhiteList []string, labelWhiteListStr string) (e
|
|||
pci.Source{},
|
||||
storage.Source{},
|
||||
system.Source{},
|
||||
custom.Source{},
|
||||
// local needs to be the last source so that it is able to override
|
||||
// labels from other sources
|
||||
local.Source{},
|
||||
|
|
Loading…
Reference in a new issue