2020-08-11 10:57:51 +03:00
|
|
|
/*
|
2021-03-01 11:00:11 +02:00
|
|
|
Copyright 2020-2021 The Kubernetes Authors.
|
2020-08-11 10:57:51 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package rules
|
|
|
|
|
|
|
|
import (
|
2021-03-02 10:33:45 +02:00
|
|
|
"fmt"
|
2021-03-01 11:00:11 +02:00
|
|
|
|
2021-08-31 11:07:44 +03:00
|
|
|
nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1"
|
2021-03-02 10:33:45 +02:00
|
|
|
"sigs.k8s.io/node-feature-discovery/source/kernel"
|
2020-08-11 10:57:51 +03:00
|
|
|
)
|
|
|
|
|
2021-03-04 07:35:17 +02:00
|
|
|
// KconfigRule implements Rule for the custom source
|
|
|
|
type KconfigRule struct {
|
2021-08-31 11:07:44 +03:00
|
|
|
nfdv1alpha1.MatchExpressionSet
|
2021-03-01 11:00:11 +02:00
|
|
|
}
|
2020-08-11 10:57:51 +03:00
|
|
|
|
2022-03-03 06:42:46 +05:30
|
|
|
// Match compares the values of Kernel config provided and legacy config
|
2021-03-04 07:35:17 +02:00
|
|
|
func (r *KconfigRule) Match() (bool, error) {
|
2021-11-30 15:15:42 +02:00
|
|
|
options := kernel.GetLegacyKconfig()
|
|
|
|
if options == nil {
|
2021-03-02 10:33:45 +02:00
|
|
|
return false, fmt.Errorf("kernel config options not available")
|
|
|
|
}
|
2021-11-30 15:15:42 +02:00
|
|
|
return r.MatchValues(options)
|
2021-03-01 11:00:11 +02:00
|
|
|
}
|