mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
398deb7cc1
- Handles errors from discovery of source. - Handles panics from discovery of source using recover(). - Added tests.
28 lines
797 B
Go
28 lines
797 B
Go
package main
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Fake Source (used only for testing)
|
|
|
|
// Implements main.FeatureSource.
|
|
type fakeSource struct{}
|
|
|
|
func (s fakeSource) Name() string { return "fake" }
|
|
func (s fakeSource) Discover() ([]string, error) {
|
|
features := []string{}
|
|
|
|
// Adding three fake features.
|
|
features = append(features, "fakefeature1", "fakefeature2", "fakefeature3")
|
|
|
|
return features, nil
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Fake Panic Source (used only for testing)
|
|
|
|
// Implements main.FeatureSource.
|
|
type fakePanicSource struct{}
|
|
|
|
func (s fakePanicSource) Name() string { return "fakepanic" }
|
|
func (s fakePanicSource) Discover() ([]string, error) {
|
|
panic("fake panic error")
|
|
}
|