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

Merge pull request #1353 from AhmedGrati/feat-ignore-hidden-feature-files

feat: ignore hidden feature files
This commit is contained in:
Kubernetes Prow Robot 2023-09-19 01:29:21 -07:00 committed by GitHub
commit 2ea6d033c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View file

@ -234,10 +234,12 @@ further be used in label rules specified in
[`custom`](#custom-feature-source) feature source.
> **NOTE:** Be careful when creating and/or updating hook or feature files
> while NFD is running. In order to avoid race conditions you should write into
> a temporary file (outside the `source.d` and `features.d` directories), and,
> atomically create/update the original file by doing a filesystem move
> operation.
> while NFD is running. In order to avoid race conditions you should write
> into a temporary file, and atomically create/update the original file by
> doing a file rename operation. NFD ignores dot files,
> so temporary file can be written to the same directory and renamed
> (`.my.feature` -> `my.feature`) once file is complete. Both file names should
> (obviously) be unique for the given application.
### An example

View file

@ -248,6 +248,10 @@ func getFeaturesFromHooks() (map[string]string, error) {
for _, file := range files {
fileName := file.Name()
// ignore hidden feature file
if strings.HasPrefix(fileName, ".") {
continue
}
lines, err := runHook(fileName)
if err != nil {
klog.ErrorS(err, "failed to run hook", "fileName", fileName)
@ -324,6 +328,10 @@ func getFeaturesFromFiles() (map[string]string, error) {
for _, file := range files {
fileName := file.Name()
// ignore hidden feature file
if strings.HasPrefix(fileName, ".") {
continue
}
lines, err := getFileContent(fileName)
if err != nil {
klog.ErrorS(err, "failed to read file", "fileName", fileName)

View file

@ -0,0 +1 @@
hiddenFeatureKey=hiddenFeatureValue