1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

feat: ignore hidden feature files

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
AhmedGrati 2023-09-08 19:03:15 +01:00
parent b7aa0b2273
commit 6c895b496a
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