1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-05 16:27:05 +00:00

Merge pull request #197 from marquiz/devel/kconfig

Support non-binary kconfig options in kernel feature source
This commit is contained in:
Kubernetes Prow Robot 2019-06-07 11:44:00 -07:00 committed by GitHub
commit 8c666cbdc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ import (
"regexp"
"strings"
"k8s.io/apimachinery/pkg/util/validation"
"sigs.k8s.io/node-feature-discovery/source"
)
@ -70,8 +71,8 @@ func (s Source) Discover() (source.Features, error) {
// Check flags
for _, opt := range Config.ConfigOpts {
if _, ok := kconfig[opt]; ok {
features["config."+opt] = true
if val, ok := kconfig[opt]; ok {
features["config."+opt] = val
}
}
@ -131,8 +132,8 @@ func readKconfigGzip(filename string) ([]byte, error) {
}
// Read kconfig into a map
func parseKconfig() (map[string]bool, error) {
kconfig := map[string]bool{}
func parseKconfig() (map[string]string, error) {
kconfig := map[string]string{}
raw := []byte(nil)
err := error(nil)
@ -175,7 +176,14 @@ func parseKconfig() (map[string]bool, error) {
for _, line := range lines {
if m := re.FindStringSubmatch(string(line)); m != nil {
if m[2] == "y" || m[2] == "m" {
kconfig[m[1]] = true
kconfig[m[1]] = "true"
} else {
value := strings.Trim(m[2], `"`)
if len(value) > validation.LabelValueMaxLength {
logger.Printf("WARNING: ignoring kconfig option '%s': value exceeds max length of %d characters", m[1], validation.LabelValueMaxLength)
continue
}
kconfig[m[1]] = value
}
}
}